Enable/disable the default null validator for non null columns, makes it possible todo the checks later on when saving, when for example autosave is disabled. |
|
|
Request lock(s) for a foundset, can be a normal or related foundset. |
|
Request lock(s) for a foundset, can be a normal or related foundset. |
|
Adds a filter based on a query to all the foundsets based on a table. |
|
Adds a filter based on a query to all the foundsets based on a table. |
|
Adds a filter to all the foundsets based on a table. |
|
Adds a filter to all the foundsets based on a table. |
|
Adds a filter to all the foundsets based on a table. |
|
Adds a filter to all the foundsets based on a table. |
|
Add tracking info used in the log table. |
|
Returns true if a transaction is committed; rollback if commit fails. |
|
Returns true if a transaction is committed; rollback if commit fails. |
|
Returns true if a transaction is committed; rollback if commit fails. |
|
Creates a foundset that combines all the records of the specified one-to-many relation seen from the given parent/primary foundset. |
|
Creates a foundset that combines all the records of the specified one-to-many relation seen from the given parent/primary foundset. |
|
Converts the argument to a JSDataSet, possible use in controller. |
|
Converts the argument to a JSDataSet, possible use in controller. |
|
Converts the argument to a JSDataSet, possible use in controller. |
|
Converts the argument to a JSDataSet, possible use in controller. |
|
Converts the argument to a JSDataSet, possible use in controller. |
|
Copies all matching non empty columns (if overwrite boolean is given all columns except pk/ident, if array then all columns except pk and array names). |
|
Copies all matching non empty columns (if overwrite boolean is given all columns except pk/ident, if array then all columns except pk and array names). |
|
Copies all matching non empty columns (if overwrite boolean is given all columns except pk/ident, if array then all columns except pk and array names). |
|
Performs a query and saves the result in a datasource. |
|
Performs a query and saves the result in a datasource. |
|
Performs a query and saves the result in a datasource. |
|
Performs a query and saves the result in a datasource. |
|
Performs a sql query on the specified server, saves the the result in a datasource. |
|
Performs a sql query on the specified server, saves the the result in a datasource. |
|
Performs a sql query on the specified server, saves the the result in a datasource. |
|
Returns an empty dataset object. |
|
Returns an empty dataset object. |
|
Returns an empty dataset object. |
|
Create a QueryBuilder object for a datasource. |
|
Create a QueryBuilder object for a datasource with given table alias. |
|
Check wether a data source exists. |
|
Returns true or false if autosave is enabled or disabled. |
|
Retrieves a list with names of all database servers that have property DataModelCloneFrom equal to the server name parameter. |
|
Performs a sql query with a query builder object. |
|
Performs a sql query with a query builder object. |
|
Performs a sql query on the specified server, returns the result in a dataset. |
|
Returns the datasource corresponding to the given server/table. |
|
Returns the server name from the datasource, or null if not a database datasource. |
|
Returns the table name from the datasource, or null if not a database datasource. |
|
Returns the database product name as supplied by the driver for a server. |
|
Returns an array of edited records with outstanding (unsaved) data. |
|
Returns an array of edited records with outstanding (unsaved) data. |
|
Returns an array of records that fail after a save. |
|
Returns an array of records that fail after a save. |
|
Returns a foundset object for a specified pk query. |
|
Returns a foundset object for a specified datasource or server and tablename. |
|
Returns a foundset object for a specified datasource or server and tablename. |
|
Returns the total number of records in a foundset. |
|
Returns a JSFoundsetUpdater object that can be used to update all or a specific number of rows in the specified foundset. |
|
Returns a named foundset object created under a specific name. |
|
Gets the next sequence for a column which has a sequence defined in its column dataprovider properties. |
|
Returns the internal SQL which defines the specified (related)foundset. |
|
Returns the internal SQL which defines the specified (related)foundset. |
|
Returns the internal SQL parameters, as an array, that are used to define the specified (related)foundset. |
|
Returns the internal SQL parameters, as an array, that are used to define the specified (related)foundset. |
|
Returns an array with all the server names used in the solution. |
|
Returns the JSTable object from which more info can be obtained (like columns). |
|
Returns the JSTable object from which more info can be obtained (like columns). |
|
Returns the JSTable object from which more info can be obtained (like columns). |
|
Returns the JSTable object from which more info can be obtained (like columns). |
|
Returns the total number of records(rows) in a table. |
|
Returns a two dimensional array object containing the table filter information currently applied to the servers tables. |
|
Returns a two dimensional array object containing the table filter information currently applied to the servers tables. |
|
Returns an array of all table names for a specified server. |
|
Returns an array of all view names for a specified server. |
|
Returns true if the current client has any or the specified lock(s) acquired. |
|
Returns true if the current client has any or the specified lock(s) acquired. |
|
Returns true if the argument (foundSet / record) has at least one row that was not yet saved in the database. |
|
Returns true if the argument (foundSet / record) has at least one row that was not yet saved in the database. |
|
Returns true if the specified foundset, on a specific index or in any of its records, or the specified record has changes. |
|
Returns true if the specified foundset, on a specific index or in any of its records, or the specified record has changes. |
|
Returns true if the (related)foundset exists and has records. |
|
Returns true if the (related)foundset exists and has records. |
|
Returns true if there is an transaction active for this client. |
|
Merge records from the same foundset, updates entire datamodel (via foreign type on columns) with destination
record pk, deletes source record. |
|
Merge records from the same foundset, updates entire datamodel (via foreign type on columns) with destination
record pk, deletes source record. |
|
Can be used to recalculate a specified record or all rows in the specified foundset. |
|
Flushes the client data cache and requeries the data for a record (based on the record index) in a foundset or all records in the foundset. |
|
Release all current locks the client has (optionally limited to named locks). |
|
Release all current locks the client has (optionally limited to named locks). |
|
Removes a previously defined table filter. |
|
Reverts outstanding (not saved) in memory changes from edited records. |
|
Reverts outstanding (not saved) in memory changes from edited records. |
|
Rollback a transaction started by databaseManager. |
|
Rollback a transaction started by databaseManager. |
|
Rollback a transaction started by databaseManager. |
|
Saves all outstanding (unsaved) data and exits the current record. |
|
Saves all outstanding (unsaved) data and exits the current record. |
|
Saves all outstanding (unsaved) data and exits the current record. |
|
Set autosave, if false then no saves will happen by the ui (not including deletes!). |
|
Turnoff the initial form foundset record loading, set this in the solution open method. |
|
Start a database transaction. |
|
Switches a named server to another named server with the same datamodel (recommended to be used in an onOpen method for a solution). |
|
|
nullColumnValidatorEnabled |
|
Enable/disable the default null validator for non null columns, makes it possible todo the checks later on when saving, when for example autosave is disabled. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample databaseManager.nullColumnValidatorEnabled = false;//disable
//test if enabled
if(databaseManager.nullColumnValidatorEnabled) application.output('null validation enabled') |
|
|
|
|
|
acquireLock(foundset, recordIndex) |
|
Request lock(s) for a foundset, can be a normal or related foundset.
The record_index can be -1 to lock all rows, 0 to lock the current row, or a specific row of > 0
Optionally name the lock(s) so that it can be referenced it in releaseAllLocks()
returns true if the lock could be acquired. |
|
|
Parameters The JSFoundset to get the lock for |
|
The record index which should be locked. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //locks the complete foundset
databaseManager.acquireLock(foundset,-1);
//locks the current row
databaseManager.acquireLock(foundset,0);
//locks all related orders for the current Customer
var success = databaseManager.acquireLock(Cust_to_Orders,-1);
if(!success)
{
plugins.dialogs.showWarningDialog('Alert','Failed to get a lock','OK');
} |
|
|
|
|
acquireLock(foundset, recordIndex, lockName) |
|
Request lock(s) for a foundset, can be a normal or related foundset.
The record_index can be -1 to lock all rows, 0 to lock the current row, or a specific row of > 0
Optionally name the lock(s) so that it can be referenced it in releaseAllLocks()
returns true if the lock could be acquired. |
|
|
Parameters The JSFoundset to get the lock for |
|
The record index which should be locked. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //locks the complete foundset
databaseManager.acquireLock(foundset,-1);
//locks the current row
databaseManager.acquireLock(foundset,0);
//locks all related orders for the current Customer
var success = databaseManager.acquireLock(Cust_to_Orders,-1);
if(!success)
{
plugins.dialogs.showWarningDialog('Alert','Failed to get a lock','OK');
} |
|
|
|
|
addTableFilterParam(query) |
|
Adds a filter based on a query to all the foundsets based on a table.
Filters on tables touched in the query will not be applied to the query filter.
For example, when a table filter exists on the order_details table,
a query filter with a join from orders to order_details will be applied to queries on the orders table,
but the filter condition on the orders_details table will not be included.
returns true if the tablefilter could be applied. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that
var query = datasources.db.example_data.orders.createSelect();
query.where.add(
query.or.add(
query.columns.shipcity.eq('Amersfoort'))
.add( query.columns.shipcity.eq('Amsterdam')));
var success = databaseManager.addTableFilterParam(query, 'cityFilter') |
|
|
|
|
addTableFilterParam(query, filterName) |
|
Adds a filter based on a query to all the foundsets based on a table.
Filters on tables touched in the query will not be applied to the query filter.
For example, when a table filter exists on the order_details table,
a query filter with a join from orders to order_details will be applied to queries on the orders table,
but the filter condition on the orders_details table will not be included.
returns true if the tablefilter could be applied. |
|
|
Parameters The specified name of the database table filter. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that
var query = datasources.db.example_data.orders.createSelect();
query.where.add(
query.or.add(
query.columns.shipcity.eq('Amersfoort'))
.add( query.columns.shipcity.eq('Amsterdam')));
var success = databaseManager.addTableFilterParam(query, 'cityFilter') |
|
|
|
|
addTableFilterParam(datasource, dataprovider, operator, value) |
|
Adds a filter to all the foundsets based on a table.
Note: if null is provided as the tablename the filter will be applied on all tables with the dataprovider name.
A dataprovider can have multiple filters defined, they will all be applied.
returns true if the tablefilter could be applied. |
|
|
Parameters A specified dataprovider column name. |
|
One of "=, <, >, >=, <=, !=, LIKE, or IN" optionally augmented with modifiers "#" (ignore case) or "^||" (or-is-null). |
|
The specified filter value. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that multiple filters can be added to the same dataprovider, they will all be applied.
// filter on messages table where messagesid>10, the filter has a name so it can be removed using databaseManager.removeTableFilterParam()
var success = databaseManager.addTableFilterParam('admin', 'messages', 'messagesid', '>', 10, 'higNumberedMessagesRule')
// all tables that have the companyid column should be filtered
var success = databaseManager.addTableFilterParam('crm', null, 'companyidid', '=', currentcompanyid)
// some filters with in-conditions
var success = databaseManager.addTableFilterParam('crm', 'products', 'productcode', 'in', [120, 144, 200])
var success = databaseManager.addTableFilterParam('crm', 'orders', 'countrycode', 'in', 'select country code from countries where region = "Europe"')
// you can use modifiers in the operator as well, filter on companies where companyname is null or equals-ignore-case 'servoy'
var success = databaseManager.addTableFilterParam('crm', 'companies', 'companyname', '#^||=', 'servoy')
// the value may be null, this will result in 'column is null' sql condition.
var success = databaseManager.addTableFilterParam('crm', 'companies', 'verified', '=', null)
//if you want to add a filter for a column (created by you) in the i18n table
databaseManager.addTableFilterParam('database', 'your_i18n_table', 'message_variant', 'in', [1, 2]) |
|
|
|
|
addTableFilterParam(datasource, dataprovider, operator, value, filterName) |
|
Adds a filter to all the foundsets based on a table.
Note: if null is provided as the tablename the filter will be applied on all tables with the dataprovider name.
A dataprovider can have multiple filters defined, they will all be applied.
returns true if the tablefilter could be applied. |
|
|
Parameters A specified dataprovider column name. |
|
One of "=, <, >, >=, <=, !=, LIKE, or IN" optionally augmented with modifiers "#" (ignore case) or "^||" (or-is-null). |
|
The specified filter value. |
|
The specified name of the database table filter. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that multiple filters can be added to the same dataprovider, they will all be applied.
// filter on messages table where messagesid>10, the filter has a name so it can be removed using databaseManager.removeTableFilterParam()
var success = databaseManager.addTableFilterParam('admin', 'messages', 'messagesid', '>', 10, 'higNumberedMessagesRule')
// all tables that have the companyid column should be filtered
var success = databaseManager.addTableFilterParam('crm', null, 'companyidid', '=', currentcompanyid)
// some filters with in-conditions
var success = databaseManager.addTableFilterParam('crm', 'products', 'productcode', 'in', [120, 144, 200])
var success = databaseManager.addTableFilterParam('crm', 'orders', 'countrycode', 'in', 'select country code from countries where region = "Europe"')
// you can use modifiers in the operator as well, filter on companies where companyname is null or equals-ignore-case 'servoy'
var success = databaseManager.addTableFilterParam('crm', 'companies', 'companyname', '#^||=', 'servoy')
// the value may be null, this will result in 'column is null' sql condition.
var success = databaseManager.addTableFilterParam('crm', 'companies', 'verified', '=', null)
//if you want to add a filter for a column (created by you) in the i18n table
databaseManager.addTableFilterParam('database', 'your_i18n_table', 'message_variant', 'in', [1, 2]) |
|
|
|
|
addTableFilterParam(serverName, tableName, dataprovider, operator, value) |
|
Adds a filter to all the foundsets based on a table.
Note: if null is provided as the tablename the filter will be applied on all tables with the dataprovider name.
A dataprovider can have multiple filters defined, they will all be applied.
returns true if the tablefilter could be applied. |
|
|
Parameters The name of the database server connection for the specified table name. |
|
The name of the specified table. |
|
A specified dataprovider column name. |
|
One of "=, <, >, >=, <=, !=, LIKE, or IN" optionally augmented with modifiers "#" (ignore case) or "^||" (or-is-null). |
|
The specified filter value. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that multiple filters can be added to the same dataprovider, they will all be applied.
// filter on messages table where messagesid>10, the filter has a name so it can be removed using databaseManager.removeTableFilterParam()
var success = databaseManager.addTableFilterParam('admin', 'messages', 'messagesid', '>', 10, 'higNumberedMessagesRule')
// all tables that have the companyid column should be filtered
var success = databaseManager.addTableFilterParam('crm', null, 'companyidid', '=', currentcompanyid)
// some filters with in-conditions
var success = databaseManager.addTableFilterParam('crm', 'products', 'productcode', 'in', [120, 144, 200])
var success = databaseManager.addTableFilterParam('crm', 'orders', 'countrycode', 'in', 'select country code from countries where region = "Europe"')
// you can use modifiers in the operator as well, filter on companies where companyname is null or equals-ignore-case 'servoy'
var success = databaseManager.addTableFilterParam('crm', 'companies', 'companyname', '#^||=', 'servoy')
// the value may be null, this will result in 'column is null' sql condition.
var success = databaseManager.addTableFilterParam('crm', 'companies', 'verified', '=', null)
//if you want to add a filter for a column (created by you) in the i18n table
databaseManager.addTableFilterParam('database', 'your_i18n_table', 'message_variant', 'in', [1, 2]) |
|
|
|
|
addTableFilterParam(serverName, tableName, dataprovider, operator, value, filterName) |
|
Adds a filter to all the foundsets based on a table.
Note: if null is provided as the tablename the filter will be applied on all tables with the dataprovider name.
A dataprovider can have multiple filters defined, they will all be applied.
returns true if the tablefilter could be applied. |
|
|
Parameters The name of the database server connection for the specified table name. |
|
The name of the specified table. |
|
A specified dataprovider column name. |
|
One of "=, <, >, >=, <=, !=, LIKE, or IN" optionally augmented with modifiers "#" (ignore case) or "^||" (or-is-null). |
|
The specified filter value. |
|
The specified name of the database table filter. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // Best way to call this in a global solution startup method, but filters may be added/removed at any time.
// Note that multiple filters can be added to the same dataprovider, they will all be applied.
// filter on messages table where messagesid>10, the filter has a name so it can be removed using databaseManager.removeTableFilterParam()
var success = databaseManager.addTableFilterParam('admin', 'messages', 'messagesid', '>', 10, 'higNumberedMessagesRule')
// all tables that have the companyid column should be filtered
var success = databaseManager.addTableFilterParam('crm', null, 'companyidid', '=', currentcompanyid)
// some filters with in-conditions
var success = databaseManager.addTableFilterParam('crm', 'products', 'productcode', 'in', [120, 144, 200])
var success = databaseManager.addTableFilterParam('crm', 'orders', 'countrycode', 'in', 'select country code from countries where region = "Europe"')
// you can use modifiers in the operator as well, filter on companies where companyname is null or equals-ignore-case 'servoy'
var success = databaseManager.addTableFilterParam('crm', 'companies', 'companyname', '#^||=', 'servoy')
// the value may be null, this will result in 'column is null' sql condition.
var success = databaseManager.addTableFilterParam('crm', 'companies', 'verified', '=', null)
//if you want to add a filter for a column (created by you) in the i18n table
databaseManager.addTableFilterParam('database', 'your_i18n_table', 'message_variant', 'in', [1, 2]) |
|
|
|
|
addTrackingInfo(columnName, value) |
|
Add tracking info used in the log table.
When tracking is enabled and a new row is inserted in the log table,
if it has a column named 'columnName', its value will be set with 'value' |
|
|
Parameters The name of the column in the log table, used for tracking info |
|
The value to be set when inserting a new row in the log table, for the 'columnName' column |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample databaseManager.addTrackingInfo('log_column_name', 'trackingInfo') |
|
|
|
|
Returns true if a transaction is committed; rollback if commit fails.
Saves all edited records and commits the data. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
} |
|
|
|
|
commitTransaction(saveFirst) |
|
Returns true if a transaction is committed; rollback if commit fails. |
|
|
Parameters save edited records to the database first (default true) |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
} |
|
|
|
|
commitTransaction(saveFirst, revertSavedRecords) |
|
Returns true if a transaction is committed; rollback if commit fails. |
|
|
Parameters save edited records to the database first (default true) |
|
if a commit fails and a rollback is done, the when given false the records are not reverted to the database state (and are in edited records again) |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
} |
|
|
|
|
convertFoundSet(foundset, related) |
|
Creates a foundset that combines all the records of the specified one-to-many relation seen from the given parent/primary foundset.
The created foundset will not contain records that have not been saved in the database, because the records in the foundset will be the
result of a select query to the database. |
|
|
Parameters The JSFoundset to convert. |
|
can be a one-to-many relation object or the name of a one-to-many relation |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // Convert in the order form a orders foundset into a orderdetails foundset,
// that has all the orderdetails from all the orders in the foundset.
var convertedFoundSet = databaseManager.convertFoundSet(foundset,order_to_orderdetails);
// or var convertedFoundSet = databaseManager.convertFoundSet(foundset,"order_to_orderdetails");
forms.orderdetails.controller.showRecords(convertedFoundSet); |
|
|
|
|
convertFoundSet(foundset, related) |
|
Creates a foundset that combines all the records of the specified one-to-many relation seen from the given parent/primary foundset.
The created foundset will not contain records that have not been saved in the database, because the records in the foundset will be the
result of a select query to the database. |
|
|
Parameters The JSFoundset to convert. |
|
the name of a one-to-many relation |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // Convert in the order form a orders foundset into a orderdetails foundset,
// that has all the orderdetails from all the orders in the foundset.
var convertedFoundSet = databaseManager.convertFoundSet(foundset,order_to_orderdetails);
// or var convertedFoundSet = databaseManager.convertFoundSet(foundset,"order_to_orderdetails");
forms.orderdetails.controller.showRecords(convertedFoundSet); |
|
|
|
|
convertToDataSet(foundset) |
|
Converts the argument to a JSDataSet, possible use in controller.loadRecords(dataset).
The optional array of dataprovider names is used (only) to add the specified dataprovider names as columns to the dataset. |
|
|
Parameters The foundset to be converted. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // converts a foundset pks to a dataset
var dataset = databaseManager.convertToDataSet(foundset);
// converts a foundset to a dataset
//var dataset = databaseManager.convertToDataSet(foundset,['product_id','product_name']);
// converts an object array to a dataset
//var dataset = databaseManager.convertToDataSet(files,['name','path']);
// converts an array to a dataset
//var dataset = databaseManager.convertToDataSet(new Array(1,2,3,4,5,6));
// converts an string list to a dataset
//var dataset = databaseManager.convertToDataSet('4,5,6'); |
|
|
|
|
convertToDataSet(foundset, dataproviderNames) |
|
Converts the argument to a JSDataSet, possible use in controller.loadRecords(dataset).
The optional array of dataprovider names is used (only) to add the specified dataprovider names as columns to the dataset. |
|
|
Parameters The foundset to be converted. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // converts a foundset pks to a dataset
var dataset = databaseManager.convertToDataSet(foundset);
// converts a foundset to a dataset
//var dataset = databaseManager.convertToDataSet(foundset,['product_id','product_name']);
// converts an object array to a dataset
//var dataset = databaseManager.convertToDataSet(files,['name','path']);
// converts an array to a dataset
//var dataset = databaseManager.convertToDataSet(new Array(1,2,3,4,5,6));
// converts an string list to a dataset
//var dataset = databaseManager.convertToDataSet('4,5,6'); |
|
|
|
|
Converts the argument to a JSDataSet, possible use in controller.loadRecords(dataset).
The optional array of dataprovider names is used (only) to add the specified dataprovider names as columns to the dataset. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // converts a foundset pks to a dataset
var dataset = databaseManager.convertToDataSet(foundset);
// converts a foundset to a dataset
//var dataset = databaseManager.convertToDataSet(foundset,['product_id','product_name']);
// converts an object array to a dataset
//var dataset = databaseManager.convertToDataSet(files,['name','path']);
// converts an array to a dataset
//var dataset = databaseManager.convertToDataSet(new Array(1,2,3,4,5,6));
// converts an string list to a dataset
//var dataset = databaseManager.convertToDataSet('4,5,6'); |
|
|
|
|
convertToDataSet(values, dataproviderNames) |
|
Converts the argument to a JSDataSet, possible use in controller.loadRecords(dataset).
The optional array of dataprovider names is used (only) to add the specified dataprovider names as columns to the dataset. |
|
|
Parameters The property names array. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // converts a foundset pks to a dataset
var dataset = databaseManager.convertToDataSet(foundset);
// converts a foundset to a dataset
//var dataset = databaseManager.convertToDataSet(foundset,['product_id','product_name']);
// converts an object array to a dataset
//var dataset = databaseManager.convertToDataSet(files,['name','path']);
// converts an array to a dataset
//var dataset = databaseManager.convertToDataSet(new Array(1,2,3,4,5,6));
// converts an string list to a dataset
//var dataset = databaseManager.convertToDataSet('4,5,6'); |
|
|
|
|
Converts the argument to a JSDataSet, possible use in controller.loadRecords(dataset).
The optional array of dataprovider names is used (only) to add the specified dataprovider names as columns to the dataset. |
|
|
Parameters Concatenated values to be put into dataset. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // converts a foundset pks to a dataset
var dataset = databaseManager.convertToDataSet(foundset);
// converts a foundset to a dataset
//var dataset = databaseManager.convertToDataSet(foundset,['product_id','product_name']);
// converts an object array to a dataset
//var dataset = databaseManager.convertToDataSet(files,['name','path']);
// converts an array to a dataset
//var dataset = databaseManager.convertToDataSet(new Array(1,2,3,4,5,6));
// converts an string list to a dataset
//var dataset = databaseManager.convertToDataSet('4,5,6'); |
|
|
|
|
copyMatchingFields(source, destination) |
|
Copies all matching non empty columns (if overwrite boolean is given all columns except pk/ident, if array then all columns except pk and array names).
The matching requires the properties and getter functions of the source to match those of the destination; for the getter functions,
the 'get' will be removed and the remaining name will be converted to lowercase before attempting to match.
Returns true if no error occurred.
NOTE: This function could be used to store a copy of records in an archive table. Use the getRecord() function to get the record as an object.
Before trying this example, please make sure that the foundsets have some records loaded: |
|
|
Parameters The source record or (java/javascript)object to be copied. |
|
The destination record to copy to. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample otherfoundset.loadAllRecords();
for( var i = 1 ; i <= foundset.getSize() ; i++ )
{
var srcRecord = foundset.getRecord(i);
var destRecord = otherfoundset.getRecord(i);
if (srcRecord == null || destRecord == null) break;
databaseManager.copyMatchingFields(srcRecord,destRecord,true)
}
//saves any outstanding changes to the dest foundset
databaseManager.saveData();
//copying from a MailMessage JavaScript object
//var _msg = plugins.mail.receiveMail(login, password, true, 0, null, properties);
//if (_msg != null)
//{
// controller.newRecord();
// var srcObject = _msg[0];
// var destRecord = foundset.getSelectedRecord();
// databaseManager.copyMatchingFields(srcObject, destRecord, true);
// databaseManager.saveData();
//} |
|
|
|
|
copyMatchingFields(source, destination, overwrite) |
|
Copies all matching non empty columns (if overwrite boolean is given all columns except pk/ident, if array then all columns except pk and array names).
The matching requires the properties and getter functions of the source to match those of the destination; for the getter functions,
the 'get' will be removed and the remaining name will be converted to lowercase before attempting to match.
Returns true if no error occurred.
NOTE: This function could be used to store a copy of records in an archive table. Use the getRecord() function to get the record as an object.
Before trying this example, please make sure that the foundsets have some records loaded: |
|
|
Parameters The source record or (java/javascript)object to be copied. |
|
The destination record to copy to. |
|
Boolean values to overwrite all values. If overwrite is false/not provided, then the non empty values are not overwritten in the destination record. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample otherfoundset.loadAllRecords();
for( var i = 1 ; i <= foundset.getSize() ; i++ )
{
var srcRecord = foundset.getRecord(i);
var destRecord = otherfoundset.getRecord(i);
if (srcRecord == null || destRecord == null) break;
databaseManager.copyMatchingFields(srcRecord,destRecord,true)
}
//saves any outstanding changes to the dest foundset
databaseManager.saveData();
//copying from a MailMessage JavaScript object
//var _msg = plugins.mail.receiveMail(login, password, true, 0, null, properties);
//if (_msg != null)
//{
// controller.newRecord();
// var srcObject = _msg[0];
// var destRecord = foundset.getSelectedRecord();
// databaseManager.copyMatchingFields(srcObject, destRecord, true);
// databaseManager.saveData();
//} |
|
|
|
|
copyMatchingFields(source, destination, names) |
|
Copies all matching non empty columns (if overwrite boolean is given all columns except pk/ident, if array then all columns except pk and array names).
The matching requires the properties and getter functions of the source to match those of the destination; for the getter functions,
the 'get' will be removed and the remaining name will be converted to lowercase before attempting to match.
Returns true if no error occurred.
NOTE: This function could be used to store a copy of records in an archive table. Use the getRecord() function to get the record as an object.
Before trying this example, please make sure that the foundsets have some records loaded: |
|
|
Parameters The source record or (java/javascript)object to be copied. |
|
The destination record to copy to. |
|
The property names that shouldn't be overriden. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample otherfoundset.loadAllRecords();
for( var i = 1 ; i <= foundset.getSize() ; i++ )
{
var srcRecord = foundset.getRecord(i);
var destRecord = otherfoundset.getRecord(i);
if (srcRecord == null || destRecord == null) break;
databaseManager.copyMatchingFields(srcRecord,destRecord,true)
}
//saves any outstanding changes to the dest foundset
databaseManager.saveData();
//copying from a MailMessage JavaScript object
//var _msg = plugins.mail.receiveMail(login, password, true, 0, null, properties);
//if (_msg != null)
//{
// controller.newRecord();
// var srcObject = _msg[0];
// var destRecord = foundset.getSelectedRecord();
// databaseManager.copyMatchingFields(srcObject, destRecord, true);
// databaseManager.saveData();
//} |
|
|
|
|
createDataSourceByQuery(name, query, useTableFilters, max_returned_rows, types, pkNames) |
|
Performs a query and saves the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data. |
|
|
Parameters The query builder to be executed. |
|
use table filters (default true). |
|
The maximum number of rows returned by the query. |
|
The column types, when null the types are inferred from the query. |
|
array of pk names, when null a hidden pk-column will be added |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // select customer data for order 1234
var q = datasources.db.example_data.customers.createSelect()
q.result.add(q.columns.customer_id).add(q.columns.city).add(q.columns.country);
q.where.add(q.joins.customers_to_orders.columns.orderid.eq(1234));
var uri = databaseManager.createDataSourceByQuery('mydata', q, true, 999, null, ['customer_id']);
//var uri = databaseManager.createDataSourceByQuery('mydata', q, true, 999, [JSColumn.TEXT, JSColumn.TEXT, JSColumn.TEXT], ['customer_id']);
// the uri can be used to create a form using solution model
var myForm = solutionModel.newForm('newForm', uri, 'myStyleName', false, 800, 600);
myForm.newTextField('city', 140, 20, 140,20);
// the uri can be used to acces a foundset directly
var fs = databaseManager.getFoundSet(uri);
fs.loadAllRecords(); |
|
|
|
|
createDataSourceByQuery(name, query, max_returned_rows) |
|
Performs a query and saves the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data. |
|
|
Parameters The query builder to be executed. |
|
The maximum number of rows returned by the query. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // select customer data for order 1234
var q = datasources.db.example_data.customers.createSelect()
q.result.add(q.columns.customer_id).add(q.columns.city).add(q.columns.country);
q.where.add(q.joins.customers_to_orders.columns.orderid.eq(1234));
var uri = databaseManager.createDataSourceByQuery('mydata', q, true, 999, null, ['customer_id']);
//var uri = databaseManager.createDataSourceByQuery('mydata', q, true, 999, [JSColumn.TEXT, JSColumn.TEXT, JSColumn.TEXT], ['customer_id']);
// the uri can be used to create a form using solution model
var myForm = solutionModel.newForm('newForm', uri, 'myStyleName', false, 800, 600);
myForm.newTextField('city', 140, 20, 140,20);
// the uri can be used to acces a foundset directly
var fs = databaseManager.getFoundSet(uri);
fs.loadAllRecords(); |
|
|
|
|
createDataSourceByQuery(name, query, max_returned_rows, types) |
|
Performs a query and saves the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
Using this variation of createDataSourceByQuery any Tablefilter on the involved tables will be taken into account.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data. |
|
|
Parameters The query builder to be executed. |
|
The maximum number of rows returned by the query. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // select customer data for order 1234
var q = datasources.db.example_data.customers.createSelect();
q.result.add(q.columns.address).add(q.columns.city).add(q.columns.country);
q.where.add(q.joins.customers_to_orders.columns.orderid.eq(1234));
var uri = databaseManager.createDataSourceByQuery('mydata', q, 999);
//var uri = databaseManager.createDataSourceByQuery('mydata', q, 999, [JSColumn.TEXT, JSColumn.TEXT, JSColumn.TEXT]);
// the uri can be used to create a form using solution model
var myForm = solutionModel.newForm('newForm', uri, 'myStyleName', false, 800, 600);
myForm.newTextField('city', 140, 20, 140,20);
// the uri can be used to acces a foundset directly
var fs = databaseManager.getFoundSet(uri);
fs.loadAllRecords(); |
|
|
|
|
createDataSourceByQuery(name, query, max_returned_rows, types, pkNames) |
|
Performs a query and saves the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
Using this variation of createDataSourceByQuery any Tablefilter on the involved tables will be taken into account.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data. |
|
|
Parameters The query builder to be executed. |
|
The maximum number of rows returned by the query. |
|
array of pk names, when null a hidden pk-column will be added |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // select customer data for order 1234
var q = datasources.db.example_data.customers.createSelect();
q.result.add(q.columns.customer_id).add(q.columns.city).add(q.columns.country);
q.where.add(q.joins.customers_to_orders.columns.orderid.eq(1234));
var uri = databaseManager.createDataSourceByQuery('mydata', q, 999, null, ['customer_id']);
//var uri = databaseManager.createDataSourceByQuery('mydata', q, 999, [JSColumn.TEXT, JSColumn.TEXT, JSColumn.TEXT], ['customer_id']);
// the uri can be used to create a form using solution model
var myForm = solutionModel.newForm('newForm', uri, 'myStyleName', false, 800, 600);
myForm.newTextField('city', 140, 20, 140,20);
// the uri can be used to acces a foundset directly
var fs = databaseManager.getFoundSet(uri);
fs.loadAllRecords(); |
|
|
|
|
createDataSourceByQuery(name, server_name, sql_query, arguments, max_returned_rows) |
|
Performs a sql query on the specified server, saves the the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
Using this variation of createDataSourceByQuery any Tablefilter on the involved tables will be disregarded.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data. |
|
|
Parameters The name of the server where the query should be executed. |
|
The custom sql, must start with 'select', 'call', 'with' or 'declare'. |
|
Specified arguments or null if there are no arguments. |
|
The maximum number of rows returned by the query. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var query = 'select address, city, country from customers';
var uri = databaseManager.createDataSourceByQuery('mydata', 'example_data', query, null, 999);
//var uri = databaseManager.createDataSourceByQuery('mydata', 'example_data', query, null, 999, [JSColumn.TEXT, JSColumn.TEXT, JSColumn.TEXT]);
// the uri can be used to create a form using solution model
var myForm = solutionModel.newForm('newForm', uri, 'myStyleName', false, 800, 600)
myForm.newTextField('city', 140, 20, 140,20)
// the uri can be used to acces a foundset directly
var fs = databaseManager.getFoundSet(uri)
fs.loadAllRecords(); |
|
|
|
|
createDataSourceByQuery(name, server_name, sql_query, arguments, max_returned_rows, types) |
|
Performs a sql query on the specified server, saves the the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
Using this variation of createDataSourceByQuery any Tablefilter on the involved tables will be disregarded.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data. |
|
|
Parameters The name of the server where the query should be executed. |
|
The custom sql, must start with 'select', 'call', 'with' or 'declare'. |
|
Specified arguments or null if there are no arguments. |
|
The maximum number of rows returned by the query. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var query = 'select address, city, country from customers';
var uri = databaseManager.createDataSourceByQuery('mydata', 'example_data', query, null, 999);
//var uri = databaseManager.createDataSourceByQuery('mydata', 'example_data', query, null, 999, [JSColumn.TEXT, JSColumn.TEXT, JSColumn.TEXT]);
// the uri can be used to create a form using solution model
var myForm = solutionModel.newForm('newForm', uri, 'myStyleName', false, 800, 600)
myForm.newTextField('city', 140, 20, 140,20)
// the uri can be used to acces a foundset directly
var fs = databaseManager.getFoundSet(uri)
fs.loadAllRecords(); |
|
|
|
|
createDataSourceByQuery(name, server_name, sql_query, arguments, max_returned_rows, columnTypes, pkNames) |
|
Performs a sql query on the specified server, saves the the result in a datasource.
Will throw an exception if anything went wrong when executing the query.
Column types in the datasource are inferred from the query result or can be explicitly specified.
Using this variation of createDataSourceByQuery any Tablefilter on the involved tables will be disregarded.
A datasource can be reused if the data has the same signature (column names and types).
A new createDataSourceByQuery() call will clear the datasource contents from a previous call and insert the current data. |
|
|
Parameters The name of the server where the query should be executed. |
|
The custom sql, must start with 'select', 'call', 'with' or 'declare'. |
|
Specified arguments or null if there are no arguments. |
|
The maximum number of rows returned by the query. |
|
array of pk names, when null a hidden pk-column will be added |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var query = 'select customer_id, address, city, country from customers';
var uri = databaseManager.createDataSourceByQuery('mydata', 'example_data', query, null, 999);
//var uri = databaseManager.createDataSourceByQuery('mydata', 'example_data', query, null, 999, [JSColumn.TEXT, JSColumn.TEXT, JSColumn.TEXT], ['customer_id']);
// the uri can be used to create a form using solution model
var myForm = solutionModel.newForm('newForm', uri, 'myStyleName', false, 800, 600)
myForm.newTextField('city', 140, 20, 140,20)
// the uri can be used to acces a foundset directly
var fs = databaseManager.getFoundSet(uri)
fs.loadAllRecords(); |
|
|
|
|
Returns an empty dataset object. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // gets an empty dataset with a specifed row and column count
var dataset = databaseManager.createEmptyDataSet(10,10)
// gets an empty dataset with a specifed row count and column array
var dataset2 = databaseManager.createEmptyDataSet(10,new Array ('a','b','c','d')) |
|
|
|
|
createEmptyDataSet(rowCount, columnCount) |
|
Returns an empty dataset object. |
|
|
Parameters The number of rows in the DataSet object. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // gets an empty dataset with a specifed row and column count
var dataset = databaseManager.createEmptyDataSet(10,10)
// gets an empty dataset with a specifed row count and column array
var dataset2 = databaseManager.createEmptyDataSet(10,new Array ('a','b','c','d')) |
|
|
|
|
createEmptyDataSet(rowCount, columnNames) |
|
Returns an empty dataset object. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // gets an empty dataset with a specifed row and column count
var dataset = databaseManager.createEmptyDataSet(10,10)
// gets an empty dataset with a specifed row count and column array
var dataset2 = databaseManager.createEmptyDataSet(10,new Array ('a','b','c','d')) |
|
|
|
|
Create a QueryBuilder object for a datasource. |
|
|
Parameters The data source to build a query for. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample /** @type {QBSelect<db:/example_data/book_nodes>} */
var q = databaseManager.createSelect('db:/example_data/book_nodes');
q.result.addPk()
q.where.add(q.columns.label_text.not.isin(null))
datasources.db.example_data.book_nodes.getFoundSet().loadRecords(q) |
|
|
|
|
createSelect(dataSource, tableAlias) |
|
Create a QueryBuilder object for a datasource with given table alias.
The alias can be used inside custom queries to bind to the outer table. |
|
|
Parameters The data source to build a query for. |
|
The alias for the main table. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample /** @type {QBSelect<db:/example_data/book_nodes>} */
var q = databaseManager.createSelect('db:/example_data/book_nodes', 'b');
q.result.addPk()
q.where.add(q.columns.label_text.isin('select comment_text from book_text t where t.note_text = ? and t.node_id = b.node_id', ['test']))
datasources.db.example_data.book_nodes.getFoundSet().loadRecords(q) |
|
|
|
|
dataSourceExists(dataSource) |
|
Check wether a data source exists. This function can be used for any type of data source (db-based, in-memory). |
|
|
Parameters the datasource string to check. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample if (!databaseManager.dataSourceExists(dataSource))
{
// does not exist
} |
|
|
|
|
Returns true or false if autosave is enabled or disabled. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //Set autosave, if false then no saves will happen by the ui (not including deletes!). Until you call saveData or setAutoSave(true)
//Rollbacks in mem the records that were edited and not yet saved. Best used in combination with autosave false.
databaseManager.setAutoSave(false)
//Now let users input data
//On save or cancel, when data has been entered:
if (cancel) databaseManager.rollbackEditedRecords()
databaseManager.setAutoSave(true) |
|
|
|
|
getDataModelClonesFrom(serverName) |
|
Retrieves a list with names of all database servers that have property DataModelCloneFrom equal to the server name parameter. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var serverNames = databaseManager.getDataModelClonesFrom('myServerName'); |
|
|
|
|
getDataSetByQuery(query, useTableFilters, max_returned_rows) |
|
Performs a sql query with a query builder object.
Will throw an exception if anything did go wrong when executing the query. |
|
|
Parameters use table filters (default true). |
|
The maximum number of rows returned by the query. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // use the query froma foundset and add a condition
/** @type {QBSelect<db:/example_data/orders>} */
var q = foundset.getQuery()
q.where.add(q.joins.orders_to_order_details.columns.discount.eq(2))
var maxReturnedRows = 10;//useful to limit number of rows
var ds = databaseManager.getDataSetByQuery(q, true, maxReturnedRows);
// query: select PK from example.book_nodes where parent = 111 and(note_date is null or note_date > now)
var query = datasources.db.example_data.book_nodes.createSelect().result.addPk().root
query.where.add(query.columns.parent_id.eq(111))
.add(query.or
.add(query.columns.note_date.isNull)
.add(query.columns.note_date.gt(new Date())))
databaseManager.getDataSetByQuery(q, true, max_returned_rows) |
|
|
|
|
getDataSetByQuery(query, max_returned_rows) |
|
Performs a sql query with a query builder object.
Will throw an exception if anything did go wrong when executing the query.
Using this variation of getDataSetByQuery any Tablefilter on the involved tables will be taken into account. |
|
|
Parameters The maximum number of rows returned by the query. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // use the query froma foundset and add a condition
/** @type {QBSelect<db:/example_data/orders>} */
var q = foundset.getQuery()
q.where.add(q.joins.orders_to_order_details.columns.discount.eq(2))
var maxReturnedRows = 10;//useful to limit number of rows
var ds = databaseManager.getDataSetByQuery(q, maxReturnedRows);
// query: select PK from example.book_nodes where parent = 111 and(note_date is null or note_date > now)
var query = datasources.db.example_data.book_nodes.createSelect().result.addPk().root
query.where.add(query.columns.parent_id.eq(111))
.add(query.or
.add(query.columns.note_date.isNull)
.add(query.columns.note_date.gt(new Date())))
databaseManager.getDataSetByQuery(q, max_returned_rows) |
|
|
|
|
getDataSetByQuery(server_name, sql_query, arguments, max_returned_rows) |
|
Performs a sql query on the specified server, returns the result in a dataset.
Will throw an exception if anything did go wrong when executing the query.
Using this variation of getDataSetByQuery any Tablefilter on the involved tables will be disregarded. |
|
|
Parameters The name of the server where the query should be executed. |
|
The custom sql, must start with 'select', 'call', 'with' or 'declare'. |
|
Specified arguments or null if there are no arguments. |
|
The maximum number of rows returned by the query. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //finds duplicate records in a specified foundset
var vQuery =" SELECT companiesid from companies where company_name IN (SELECT company_name from companies group bycompany_name having count(company_name)>1 )";
var vDataset = databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(controller.getDataSource()), vQuery, null, 1000);
controller.loadRecords(vDataset);
var maxReturnedRows = 10;//useful to limit number of rows
var query = 'select c1,c2,c3 from test_table where start_date = ?';//do not use '.' or special chars in names or aliases if you want to access data by name
var args = new Array();
args[0] = order_date //or new Date()
var dataset = databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(controller.getDataSource()), query, args, maxReturnedRows);
// place in label:
// elements.myLabel.text = '<html>'+dataset.getAsHTML()+'</html>';
//example to calc a strange total
global_total = 0;
for( var i = 1 ; i <= dataset.getMaxRowIndex() ; i++ )
{
dataset.rowIndex = i;
global_total = global_total + dataset.c1 + dataset.getValue(i,3);
}
//example to assign to dataprovider
//employee_salary = dataset.getValue(row,column) |
|
|
|
|
getDataSource(serverName, tableName) |
|
Returns the datasource corresponding to the given server/table. |
|
|
Parameters The name of the table's server. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient,MobileClient |
|
|
Sample var datasource = databaseManager.getDataSource('example_data', 'categories'); |
|
|
|
|
getDataSourceServerName(dataSource) |
|
Returns the server name from the datasource, or null if not a database datasource. |
|
|
Parameters The datasource string to get the server name from. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient,MobileClient |
|
|
Sample var servername = databaseManager.getDataSourceServerName(datasource); |
|
|
|
|
getDataSourceTableName(dataSource) |
|
Returns the table name from the datasource, or null if not a database datasource. |
|
|
Parameters The datasource string to get the tablename from. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient,MobileClient |
|
|
Sample var tablename = databaseManager.getDataSourceTableName(datasource); |
|
|
|
|
getDatabaseProductName(serverName) |
|
Returns the database product name as supplied by the driver for a server.
NOTE: For more detail on named server connections, see the chapter on Database Connections, beginning with the Introduction to database connections in the Servoy Developer User's Guide. |
|
|
Parameters The specified name of the database server connection. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var databaseProductName = databaseManager.getDatabaseProductName(servername) |
|
|
|
|
Returns an array of edited records with outstanding (unsaved) data.
This is different form JSRecord.isEditing() because this call actually checks if there are changes between the current
record data and the stored data in the database. If there are no changes then the record is removed from the edited records
list (so after this call JSRecord.isEditing() can return false when it returned true just before this call)
NOTE: To return a dataset of outstanding (unsaved) edited data for each record, see JSRecord.getChangedData();
NOTE2: The fields focus may be lost in user interface in order to determine the edits. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //This method can be used to loop through all outstanding changes,
//the application.output line contains all the changed data, their tablename and primary key
var editr = databaseManager.getEditedRecords()
for (x=0;x<editr.length;x++)
{
var ds = editr[x].getChangedData();
var jstable = databaseManager.getTable(editr[x]);
var tableSQLName = jstable.getSQLName();
var pkrec = jstable.getRowIdentifierColumnNames().join(',');
var pkvals = new Array();
for (var j = 0; j < jstable.getRowIdentifierColumnNames().length; j++)
{
pkvals[j] = editr[x][jstable.getRowIdentifierColumnNames()[j]];
}
application.output('Table: '+tableSQLName +', PKs: '+ pkvals.join(',') +' ('+pkrec +')');
// Get a dataset with outstanding changes on a record
for( var i = 1 ; i <= ds.getMaxRowIndex() ; i++ )
{
application.output('Column: '+ ds.getValue(i,1) +', oldValue: '+ ds.getValue(i,2) +', newValue: '+ ds.getValue(i,3));
}
}
//in most cases you will want to set autoSave back on now
databaseManager.setAutoSave(true); |
|
|
|
|
getEditedRecords(foundset) |
|
Returns an array of edited records with outstanding (unsaved) data.
NOTE: To return a dataset of outstanding (unsaved) edited data for each record, see JSRecord.getChangedData();
NOTE2: The fields focus may be lost in user interface in order to determine the edits. |
|
|
Parameters return edited records in the foundset only. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //This method can be used to loop through all outstanding changes in a foundset,
//the application.output line contains all the changed data, their tablename and primary key
var editr = databaseManager.getEditedRecords(foundset)
for (x=0;x<editr.length;x++)
{
var ds = editr[x].getChangedData();
var jstable = databaseManager.getTable(editr[x]);
var tableSQLName = jstable.getSQLName();
var pkrec = jstable.getRowIdentifierColumnNames().join(',');
var pkvals = new Array();
for (var j = 0; j < jstable.getRowIdentifierColumnNames().length; j++)
{
pkvals[j] = editr[x][jstable.getRowIdentifierColumnNames()[j]];
}
application.output('Table: '+tableSQLName +', PKs: '+ pkvals.join(',') +' ('+pkrec +')');
// Get a dataset with outstanding changes on a record
for( var i = 1 ; i <= ds.getMaxRowIndex() ; i++ )
{
application.output('Column: '+ ds.getValue(i,1) +', oldValue: '+ ds.getValue(i,2) +', newValue: '+ ds.getValue(i,3));
}
}
databaseManager.saveData(foundset);//save all records from foundset |
|
|
|
|
Returns an array of records that fail after a save. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var array = databaseManager.getFailedRecords()
for( var i = 0 ; i < array.length ; i++ )
{
var record = array[i];
application.output(record.exception);
if (record.exception.getErrorCode() == ServoyException.RECORD_VALIDATION_FAILED)
{
// exception thrown in pre-insert/update/delete event method
var thrown = record.exception.getValue()
application.output("Record validation failed: "+thrown)
}
// find out the table of the record (similar to getEditedRecords)
var jstable = databaseManager.getTable(record);
var tableSQLName = jstable.getSQLName();
application.output('Table:'+tableSQLName+' in server:'+jstable.getServerName()+' failed to save.')
} |
|
|
|
|
getFailedRecords(foundset) |
|
Returns an array of records that fail after a save. |
|
|
Parameters return failed records in the foundset only. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var array = databaseManager.getFailedRecords(foundset)
for( var i = 0 ; i < array.length ; i++ )
{
var record = array[i];
application.output(record.exception);
if (record.exception.getErrorCode() == ServoyException.RECORD_VALIDATION_FAILED)
{
// exception thrown in pre-insert/update/delete event method
var thrown = record.exception.getValue()
application.output("Record validation failed: "+thrown)
}
// find out the table of the record (similar to getEditedRecords)
var jstable = databaseManager.getTable(record);
var tableSQLName = jstable.getSQLName();
application.output('Table:'+tableSQLName+' in server:'+jstable.getServerName()+' failed to save.')
} |
|
|
|
|
Returns a foundset object for a specified pk query. |
|
|
Parameters The query to get the JSFoundset for. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // type the foundset returned from the call with JSDoc, fill in the right server/tablename
/** @type {JSFoundset<db:/servername/tablename>} */
var fs = databaseManager.getFoundSet(controller.getDataSource())
// same as datasources.db.example_data.orders.getFoundSet() or datasources.mem['myds'].getFoundSet()
var ridx = fs.newRecord()
var record = fs.getRecord(ridx)
record.emp_name = 'John'
databaseManager.saveData() |
|
|
|
|
Returns a foundset object for a specified datasource or server and tablename.
Alternative method: datasources.db.server_name.table_name.getFoundSet() or datasources.mem['ds'].getFoundSet() |
|
|
Parameters The datasource to get a JSFoundset for. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient,MobileClient |
|
|
Sample // type the foundset returned from the call with JSDoc, fill in the right server/tablename
/** @type {JSFoundset<db:/servername/tablename>} */
var fs = databaseManager.getFoundSet(controller.getDataSource())
// same as datasources.db.example_data.orders.getFoundSet() or datasources.mem['myds'].getFoundSet()
var ridx = fs.newRecord()
var record = fs.getRecord(ridx)
record.emp_name = 'John'
databaseManager.saveData() |
|
|
|
|
getFoundSet(serverName, tableName) |
|
Returns a foundset object for a specified datasource or server and tablename. |
|
|
Parameters The servername to get a JSFoundset for. |
|
The tablename for that server |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // type the foundset returned from the call with JSDoc, fill in the right server/tablename
/** @type {JSFoundset<db:/servername/tablename>} */
var fs = databaseManager.getFoundSet(controller.getDataSource())
// same as datasources.db.example_data.orders.getFoundSet() or datasources.mem['myds'].getFoundSet()
var ridx = fs.newRecord()
var record = fs.getRecord(ridx)
record.emp_name = 'John'
databaseManager.saveData() |
|
|
|
|
getFoundSetCount(foundset) |
|
Returns the total number of records in a foundset.
NOTE: This can be an expensive operation (time-wise) if your resultset is large. |
|
|
Parameters The JSFoundset to get the count for. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //return the total number of records in a foundset.
databaseManager.getFoundSetCount(foundset); |
|
|
|
|
getFoundSetUpdater(foundset) |
|
Returns a JSFoundsetUpdater object that can be used to update all or a specific number of rows in the specified foundset. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //1) update entire foundset
var fsUpdater = databaseManager.getFoundSetUpdater(foundset)
fsUpdater.setColumn('customer_type',1)
fsUpdater.setColumn('my_flag',0)
fsUpdater.performUpdate()
//2) update part of foundset, for example the first 4 row (starts with selected row)
var fsUpdater = databaseManager.getFoundSetUpdater(foundset)
fsUpdater.setColumn('customer_type',new Array(1,2,3,4))
fsUpdater.setColumn('my_flag',new Array(1,0,1,0))
fsUpdater.performUpdate()
//3) safely loop through foundset (starts with selected row)
controller.setSelectedIndex(1)
var count = 0
var fsUpdater = databaseManager.getFoundSetUpdater(foundset)
while(fsUpdater.next())
{
fsUpdater.setColumn('my_flag',count++)
} |
|
|
|
|
Returns a named foundset object created under a specific name. If foundset does not exist, null will be returned.
Alternative method: datasources.db.server_name.table_name.getFoundSet(name) |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // type the foundset returned from the call with JSDoc, fill in the right server/tablename
/** @type {JSFoundset<db:/servername/tablename>} */
var fs = databaseManager.getNamedFoundSet('myname')
// same as datasources.db.example_data.orders.getFoundSet('myname')
var ridx = fs.newRecord()
var record = fs.getRecord(ridx)
record.emp_name = 'John'
databaseManager.saveData() |
|
|
|
|
getNextSequence(dataSource, columnName) |
|
Gets the next sequence for a column which has a sequence defined in its column dataprovider properties.
NOTE: For more infomation on configuring the sequence for a column, see the section Auto enter options for a column from the Dataproviders chapter in the Servoy Developer User's Guide. |
|
|
Parameters The datasource that points to the table which has the column with the sequence,
or the name of the server where the table can be found. If the name of the server
is specified, then a second optional parameter specifying the name of the table
must be used. If the datasource is specified, then the name of the table is not needed
as the second argument. |
|
The name of the column that has a sequence defined in its properties. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var seqDataSource = forms.seq_table.controller.getDataSource();
var nextValue = databaseManager.getNextSequence(seqDataSource, 'seq_table_value');
application.output(nextValue);
nextValue = databaseManager.getNextSequence(databaseManager.getDataSourceServerName(seqDataSource), databaseManager.getDataSourceTableName(seqDataSource), 'seq_table_value')
application.output(nextValue); |
|
|
|
|
getSQL(foundsetOrQBSelect) |
|
Returns the internal SQL which defines the specified (related)foundset.
Table filters are on by default.
Make sure to set the applicable filters when the sql is used in a loadRecords() call. |
|
|
Parameters The JSFoundset or QBSelect to get the sql for. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var sql = databaseManager.getSQL(foundset) |
|
|
|
|
getSQL(foundsetOrQBSelect, includeFilters) |
|
Returns the internal SQL which defines the specified (related)foundset.
Optionally, the foundset and table filter params can be excluded in the sql (includeFilters=false).
Make sure to set the applicable filters when the sql is used in a loadRecords() call.
When the founset is in find mode, the find conditions are included in the resulting query. |
|
|
Parameters The JSFoundset or QBSelect to get the sql for. |
|
include the foundset and table filters. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var sql = databaseManager.getSQL(foundset) |
|
|
|
|
getSQLParameters(foundsetOrQBSelect) |
|
Returns the internal SQL parameters, as an array, that are used to define the specified (related)foundset.
Parameters for the filters are included. |
|
|
Parameters The JSFoundset or QBSelect to get the sql parameters for. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var sqlParameterArray = databaseManager.getSQLParameters(foundset,false) |
|
|
|
|
getSQLParameters(foundsetOrQBSelect, includeFilters) |
|
Returns the internal SQL parameters, as an array, that are used to define the specified (related)foundset.
When the founset is in find mode, the arguments for the find conditions are included in the result. |
|
|
Parameters The JSFoundset or QBSelect to get the sql parameters for. |
|
include the parameters for the filters. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var sqlParameterArray = databaseManager.getSQLParameters(foundset,false) |
|
|
|
|
Returns an array with all the server names used in the solution.
NOTE: For more detail on named server connections, see the chapter on Database Connections, beginning with the Introduction to database connections in the Servoy Developer User's Guide. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var array = databaseManager.getServerNames() |
|
|
|
|
Returns the JSTable object from which more info can be obtained (like columns).
The parameter can be a JSFoundset,JSRecord,datasource string or server/tablename combination. |
|
|
Parameters The foundset where the JSTable can be get from. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var jstable = databaseManager.getTable(controller.getDataSource());
//var jstable = databaseManager.getTable(foundset);
//var jstable = databaseManager.getTable(record);
//var jstable = databaseManager.getTable(datasource);
var tableSQLName = jstable.getSQLName();
var columnNamesArray = jstable.getColumnNames();
var firstColumnName = columnNamesArray[0];
var jscolumn = jstable.getColumn(firstColumnName);
var columnLength = jscolumn.getLength();
var columnType = jscolumn.getTypeAsString();
var columnSQLName = jscolumn.getSQLName();
var isPrimaryKey = jscolumn.isRowIdentifier(); |
|
|
|
|
Returns the JSTable object from which more info can be obtained (like columns).
The parameter can be a JSFoundset,JSRecord,datasource string or server/tablename combination. |
|
|
Parameters The record where the table can be get from. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var jstable = databaseManager.getTable(controller.getDataSource());
//var jstable = databaseManager.getTable(foundset);
//var jstable = databaseManager.getTable(record);
//var jstable = databaseManager.getTable(datasource);
var tableSQLName = jstable.getSQLName();
var columnNamesArray = jstable.getColumnNames();
var firstColumnName = columnNamesArray[0];
var jscolumn = jstable.getColumn(firstColumnName);
var columnLength = jscolumn.getLength();
var columnType = jscolumn.getTypeAsString();
var columnSQLName = jscolumn.getSQLName();
var isPrimaryKey = jscolumn.isRowIdentifier(); |
|
|
|
|
Returns the JSTable object from which more info can be obtained (like columns).
The parameter can be a JSFoundset,JSRecord,datasource string or server/tablename combination. |
|
|
Parameters The datasource where the table can be get from. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var jstable = databaseManager.getTable(controller.getDataSource());
//var jstable = databaseManager.getTable(foundset);
//var jstable = databaseManager.getTable(record);
//var jstable = databaseManager.getTable(datasource);
var tableSQLName = jstable.getSQLName();
var columnNamesArray = jstable.getColumnNames();
var firstColumnName = columnNamesArray[0];
var jscolumn = jstable.getColumn(firstColumnName);
var columnLength = jscolumn.getLength();
var columnType = jscolumn.getTypeAsString();
var columnSQLName = jscolumn.getSQLName();
var isPrimaryKey = jscolumn.isRowIdentifier(); |
|
|
|
|
getTable(serverName, tableName) |
|
Returns the JSTable object from which more info can be obtained (like columns).
The parameter can be a JSFoundset,JSRecord,datasource string or server/tablename combination. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var jstable = databaseManager.getTable(controller.getDataSource());
//var jstable = databaseManager.getTable(foundset);
//var jstable = databaseManager.getTable(record);
//var jstable = databaseManager.getTable(datasource);
var tableSQLName = jstable.getSQLName();
var columnNamesArray = jstable.getColumnNames();
var firstColumnName = columnNamesArray[0];
var jscolumn = jstable.getColumn(firstColumnName);
var columnLength = jscolumn.getLength();
var columnType = jscolumn.getTypeAsString();
var columnSQLName = jscolumn.getSQLName();
var isPrimaryKey = jscolumn.isRowIdentifier(); |
|
|
|
|
getTableCount(dataSource) |
|
Returns the total number of records(rows) in a table.
NOTE: This can be an expensive operation (time-wise) if your resultset is large |
|
|
Parameters Data where a server table can be get from. Can be a foundset, a datasource name or a JSTable. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //return the total number of rows in a table.
var count = databaseManager.getTableCount(foundset); |
|
|
|
|
getTableFilterParams(serverName) |
|
Returns a two dimensional array object containing the table filter information currently applied to the servers tables.
For column-based table filters, a row of 5 fields per filter are returned.
The "columns" of a row from this array are: tablename, dataprovider, operator, value, filtername
For query-based filters, a row of 2 fields per filter are returned.
The "columns" of a row from this array are: query, filtername |
|
|
Parameters The name of the database server connection. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var params = databaseManager.getTableFilterParams(databaseManager.getDataSourceServerName(controller.getDataSource()))
for (var i = 0; params != null && i < params.length; i++)
{
if (params[i].length() == 5) {
application.output('Table filter on table ' + params[i][0] + ': '+ params[i][1] + ' '+params[i][2] + ' '+params[i][3] + (params[i][4] == null ? ' [no name]' : ' ['+params[i][4]+']'))
}
if (params[i].length() == 2) {
application.output('Table filter with query ' + params[i][0]+ ': ' + (params[i][1] == null ? ' [no name]' : ' ['+params[i][1]+']'))
}
} |
|
|
|
|
getTableFilterParams(serverName, filterName) |
|
Returns a two dimensional array object containing the table filter information currently applied to the servers tables.
For column-based table filters, a row of 5 fields per filter are returned.
The "columns" of a row from this array are: tablename, dataprovider, operator, value, filtername
For query-based filters, a row of 2 fields per filter are returned.
The "columns" of a row from this array are: query, filtername |
|
|
Parameters The name of the database server connection. |
|
The filter name for which to get the array. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var params = databaseManager.getTableFilterParams(databaseManager.getDataSourceServerName(controller.getDataSource()))
for (var i = 0; params != null && i < params.length; i++)
{
if (params[i].length() == 5) {
application.output('Table filter on table ' + params[i][0] + ': '+ params[i][1] + ' '+params[i][2] + ' '+params[i][3] + (params[i][4] == null ? ' [no name]' : ' ['+params[i][4]+']'))
}
if (params[i].length() == 2) {
application.output('Table filter with query ' + params[i][0]+ ': ' + (params[i][1] == null ? ' [no name]' : ' ['+params[i][1]+']'))
}
} |
|
|
|
|
getTableNames(serverName) |
|
Returns an array of all table names for a specified server. |
|
|
Parameters The server name to get the table names from. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //return all the table names as array
var tableNamesArray = databaseManager.getTableNames('user_data');
var firstTableName = tableNamesArray[0]; |
|
|
|
|
Returns an array of all view names for a specified server. |
|
|
Parameters The server name to get the view names from. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //return all the view names as array
var viewNamesArray = databaseManager.getViewNames('user_data');
var firstViewName = viewNamesArray[0]; |
|
|
|
|
Returns true if the current client has any or the specified lock(s) acquired. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var hasLocks = databaseManager.hasLocks('mylock') |
|
|
|
|
Returns true if the current client has any or the specified lock(s) acquired. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var hasLocks = databaseManager.hasLocks('mylock') |
|
|
|
|
Returns true if the argument (foundSet / record) has at least one row that was not yet saved in the database. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var fs = databaseManager.getFoundSet(databaseManager.getDataSourceServerName(controller.getDataSource()),'employees');
databaseManager.startTransaction();
var ridx = fs.newRecord();
var record = fs.getRecord(ridx);
record.emp_name = 'John';
if (databaseManager.hasNewRecords(fs)) {
application.output("new records");
} else {
application.output("no new records");
}
databaseManager.saveData();
databaseManager.commitTransaction(); |
|
|
|
|
hasNewRecords(foundset, index) |
|
Returns true if the argument (foundSet / record) has at least one row that was not yet saved in the database. |
|
|
Parameters The record index in the foundset to test (not specified means has the foundset any new records) |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var fs = databaseManager.getFoundSet(databaseManager.getDataSourceServerName(controller.getDataSource()),'employees');
databaseManager.startTransaction();
var ridx = fs.newRecord();
var record = fs.getRecord(ridx);
record.emp_name = 'John';
if (databaseManager.hasNewRecords(fs)) {
application.output("new records");
} else {
application.output("no new records");
}
databaseManager.saveData();
databaseManager.commitTransaction(); |
|
|
|
|
hasRecordChanges(foundset) |
|
Returns true if the specified foundset, on a specific index or in any of its records, or the specified record has changes.
NOTE: The fields focus may be lost in user interface in order to determine the edits. |
|
|
Parameters The JSFoundset to test if it has changes. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample if (databaseManager.hasRecordChanges(foundset,2))
{
//do save or something else
} |
|
|
|
|
hasRecordChanges(foundset, index) |
|
Returns true if the specified foundset, on a specific index or in any of its records, or the specified record has changes.
NOTE: The fields focus may be lost in user interface in order to determine the edits. |
|
|
Parameters The JSFoundset to test if it has changes. |
|
The record index in the foundset to test (not specified means has the foundset any changed records) |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample if (databaseManager.hasRecordChanges(foundset,2))
{
//do save or something else
} |
|
|
|
|
Returns true if the (related)foundset exists and has records. |
|
|
Supported Clients SmartClient,WebClient,NGClient,MobileClient |
|
|
Sample if (%%elementName%%.hasRecords(orders_to_orderitems))
{
//do work on relatedFoundSet
}
//if (%%elementName%%.hasRecords(foundset.getSelectedRecord(),'orders_to_orderitems.orderitems_to_products'))
//{
// //do work on deeper relatedFoundSet
//} |
|
|
|
|
hasRecords(record, relationString) |
|
Returns true if the (related)foundset exists and has records. |
|
|
Supported Clients SmartClient,WebClient,NGClient,MobileClient |
|
|
Sample if (%%elementName%%.hasRecords(orders_to_orderitems))
{
//do work on relatedFoundSet
}
//if (%%elementName%%.hasRecords(foundset.getSelectedRecord(),'orders_to_orderitems.orderitems_to_products'))
//{
// //do work on deeper relatedFoundSet
//} |
|
|
|
|
Returns true if there is an transaction active for this client. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var hasTransaction = databaseManager.hasTransaction() |
|
|
|
|
mergeRecords(sourceRecord, combinedDestinationRecord) |
|
Merge records from the same foundset, updates entire datamodel (via foreign type on columns) with destination
record pk, deletes source record. Do use a transaction!
This function is very handy in situations where duplicate data exists. It allows you to merge the two records
and move all related records in one go. Say the source_record is "Ikea" and the combined_destination_record is "IKEA", the
"Ikea" record is deleted and all records related to it (think of contacts and orders, for instance) will be related
to the "IKEA" record.
The function takes an optional array of column names. If provided, the data in the named columns will be copied
from source_record to combined_destination_record.
Note that it is essential for both records to originate from the same foundset, as shown in the sample code. |
|
|
Parameters The source JSRecord to copy from. |
|
combinedDestinationRecord |
The target/destination JSRecord to copy into. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample databaseManager.mergeRecords(foundset.getRecord(1),foundset.getRecord(2)); |
|
|
|
|
mergeRecords(sourceRecord, combinedDestinationRecord, columnNames) |
|
Merge records from the same foundset, updates entire datamodel (via foreign type on columns) with destination
record pk, deletes source record. Do use a transaction!
This function is very handy in situations where duplicate data exists. It allows you to merge the two records
and move all related records in one go. Say the source_record is "Ikea" and the combined_destination_record is "IKEA", the
"Ikea" record is deleted and all records related to it (think of contacts and orders, for instance) will be related
to the "IKEA" record.
The function takes an optional array of column names. If provided, the data in the named columns will be copied
from source_record to combined_destination_record.
Note that it is essential for both records to originate from the same foundset, as shown in the sample code. |
|
|
Parameters The source JSRecord to copy from. |
|
combinedDestinationRecord |
The target/destination JSRecord to copy into. |
|
The column names array that should be copied. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample databaseManager.mergeRecords(foundset.getRecord(1),foundset.getRecord(2)); |
|
|
|
|
recalculate(foundsetOrRecord) |
|
Can be used to recalculate a specified record or all rows in the specified foundset.
May be necessary when data is changed from outside of servoy, or when there is data changed inside servoy
but records with calculations depending on that data where not loaded so not updated and you need to update
the stored calculation values because you are depending on that with queries or aggregates. |
|
|
Parameters JSFoundset or JSRecord to recalculate. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // recalculate one record from a foundset.
databaseManager.recalculate(foundset.getRecord(1));
// recalculate all records from the foundset.
// please use with care, this can be expensive!
//databaseManager.recalculate(foundset); |
|
|
|
|
refreshRecordFromDatabase(foundset, index) |
|
Flushes the client data cache and requeries the data for a record (based on the record index) in a foundset or all records in the foundset.
Used where a program external to Servoy has modified the database record.
Record index of -1 will refresh all records in the foundset and 0 the selected record. |
|
|
Parameters The JSFoundset to refresh |
|
The index of the JSRecord that must be refreshed (or -1 for all). |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //refresh the second record from the foundset.
databaseManager.refreshRecordFromDatabase(foundset,2)
//flushes all records in the related foundset (-1 is or can be an expensive operation)
databaseManager.refreshRecordFromDatabase(order_to_orderdetails,-1); |
|
|
|
|
Release all current locks the client has (optionally limited to named locks).
return true if the locks are released. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample databaseManager.releaseAllLocks('mylock') |
|
|
|
|
releaseAllLocks(lockName) |
|
Release all current locks the client has (optionally limited to named locks).
return true if the locks are released. |
|
|
Parameters The lock name to release. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample databaseManager.releaseAllLocks('mylock') |
|
|
|
|
removeTableFilterParam(serverName, filterName) |
|
Removes a previously defined table filter. |
|
|
Parameters The name of the database server connection. |
|
The name of the filter that should be removed. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample var success = databaseManager.removeTableFilterParam('admin', 'higNumberedMessagesRule') |
|
|
|
|
Reverts outstanding (not saved) in memory changes from edited records.
Can specify a record or foundset as parameter to rollback.
Best used in combination with the function databaseManager.setAutoSave()
This does not include deletes, they do not honor the autosafe false flag so they cant be rollbacked by this call. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //Set autosave, if false then no saves will happen by the ui (not including deletes!). Until you call saveData or setAutoSave(true)
//reverts in mem the records that were edited and not yet saved. Best used in combination with autosave false.
databaseManager.setAutoSave(false)
//Now let users input data
//On save or cancel, when data has been entered:
if (cancel) databaseManager.revertEditedRecords()
//databaseManager.revertEditedRecords(foundset); // rollback all records from foundset
//databaseManager.revertEditedRecords(foundset.getSelectedRecord()); // rollback only one record
databaseManager.setAutoSave(true) |
|
|
|
|
revertEditedRecords(foundset) |
|
Reverts outstanding (not saved) in memory changes from edited records.
Can specify a record or foundset as parameter to rollback.
Best used in combination with the function databaseManager.setAutoSave()
This does not include deletes, they do not honor the autosafe false flag so they cant be rollbacked by this call. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //Set autosave, if false then no saves will happen by the ui (not including deletes!). Until you call saveData or setAutoSave(true)
//reverts in mem the records that were edited and not yet saved. Best used in combination with autosave false.
databaseManager.setAutoSave(false)
//Now let users input data
//On save or cancel, when data has been entered:
if (cancel) databaseManager.revertEditedRecords()
//databaseManager.revertEditedRecords(foundset); // rollback all records from foundset
//databaseManager.revertEditedRecords(foundset.getSelectedRecord()); // rollback only one record
databaseManager.setAutoSave(true) |
|
|
|
|
Rollback a transaction started by databaseManager.startTransaction().
Note that when autosave is false, revertEditedRecords() will not handle deleted records, while rollbackTransaction() does.
Also, rollbackEditedRecords() is called before rolling back the transaction see rollbackTransaction(boolean) to controll that behavior
and saved records within the transactions are restored to the database values, so user input is lost, to control this see rollbackTransaction(boolean,boolean) |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
} |
|
|
|
|
rollbackTransaction(rollbackEdited) |
|
Rollback a transaction started by databaseManager.startTransaction().
Note that when autosave is false, revertEditedRecords() will not handle deleted records, while rollbackTransaction() does.
Also, saved records within the transactions are restored to the database values, so user input is lost, to controll this see rollbackTransaction(boolean,boolean) |
|
|
Parameters call rollbackEditedRecords() before rolling back the transaction |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
} |
|
|
|
|
rollbackTransaction(rollbackEdited, revertSavedRecords) |
|
Rollback a transaction started by databaseManager.startTransaction().
Note that when autosave is false, revertEditedRecords() will not handle deleted records, while rollbackTransaction() does. |
|
|
Parameters call rollbackEditedRecords() before rolling back the transaction |
|
if false then all records in the transaction do keep the user input and are back in the edited records list.
Note that if the pks of such a record are no longer used by it's foundset (find/search or load by query or ...) it will just be rolled-back as
it can't be put in editing records list. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
} |
|
|
|
|
Saves all outstanding (unsaved) data and exits the current record.
Optionally, by specifying a record or foundset, can save a single record or all records from foundset instead of all the data.
Since Servoy 8.3 saveData with null parameter does not call saveData() as fallback, it just returns false.
NOTE: The fields focus may be lost in user interface in order to determine the edits.
SaveData called from table events (like afterRecordInsert) is only partially supported depeding on how first saveData (that triggers the event) is called.
If first saveData is called with no arguments, all saveData from table events are returning immediatelly with true value and records will be saved as part of first save.
If first saveData is called with record(s) as arguments, saveData from table event will try to save record(s) from arguments that are different than those in first call.
SaveData with no arguments inside table events will always return true without saving anything. |
|
|
Supported Clients SmartClient,WebClient,NGClient,MobileClient |
|
|
Sample databaseManager.saveData();
//databaseManager.saveData(foundset.getRecord(1));//save specific record
//databaseManager.saveData(foundset);//save all records from foundset
// when creating many records in a loop do a batch save on an interval as every 10 records (to save on memory and roundtrips)
// for (var recordIndex = 1; recordIndex <= 5000; recordIndex++)
// {
// foundset.newRecord();
// someColumn = recordIndex;
// anotherColumn = "Index is: " + recordIndex;
// if (recordIndex % 10 == 0) databaseManager.saveData();
// } |
|
|
|
|
Saves all outstanding (unsaved) data and exits the current record.
Optionally, by specifying a record or foundset, can save a single record or all records from foundset instead of all the data.
Since Servoy 8.3 saveData with null parameter does not call saveData() as fallback, it just returns false.
NOTE: The fields focus may be lost in user interface in order to determine the edits.
SaveData called from table events (like afterRecordInsert) is only partially supported depeding on how first saveData (that triggers the event) is called.
If first saveData is called with no arguments, all saveData from table events are returning immediatelly with true value and records will be saved as part of first save.
If first saveData is called with record(s) as arguments, saveData from table event will try to save record(s) from arguments that are different than those in first call.
SaveData with no arguments inside table events will always return true without saving anything. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample databaseManager.saveData();
//databaseManager.saveData(foundset.getRecord(1));//save specific record
//databaseManager.saveData(foundset);//save all records from foundset
// when creating many records in a loop do a batch save on an interval as every 10 records (to save on memory and roundtrips)
// for (var recordIndex = 1; recordIndex <= 5000; recordIndex++)
// {
// foundset.newRecord();
// someColumn = recordIndex;
// anotherColumn = "Index is: " + recordIndex;
// if (recordIndex % 10 == 0) databaseManager.saveData();
// } |
|
|
|
|
Saves all outstanding (unsaved) data and exits the current record.
Optionally, by specifying a record or foundset, can save a single record or all records from foundset instead of all the data.
Since Servoy 8.3 saveData with null parameter does not call saveData() as fallback, it just returns false.
NOTE: The fields focus may be lost in user interface in order to determine the edits.
SaveData called from table events (like afterRecordInsert) is only partially supported depeding on how first saveData (that triggers the event) is called.
If first saveData is called with no arguments, all saveData from table events are returning immediatelly with true value and records will be saved as part of first save.
If first saveData is called with record(s) as arguments, saveData from table event will try to save record(s) from arguments that are different than those in first call.
SaveData with no arguments inside table events will always return true without saving anything. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample databaseManager.saveData();
//databaseManager.saveData(foundset.getRecord(1));//save specific record
//databaseManager.saveData(foundset);//save all records from foundset
// when creating many records in a loop do a batch save on an interval as every 10 records (to save on memory and roundtrips)
// for (var recordIndex = 1; recordIndex <= 5000; recordIndex++)
// {
// foundset.newRecord();
// someColumn = recordIndex;
// anotherColumn = "Index is: " + recordIndex;
// if (recordIndex % 10 == 0) databaseManager.saveData();
// } |
|
|
|
|
Set autosave, if false then no saves will happen by the ui (not including deletes!).
Until you call databaseManager.saveData() or setAutoSave(true)
If you also want to be able to rollback deletes then you have to use databaseManager.startTransaction().
Because even if autosave is false deletes of records will be done. |
|
|
Parameters Boolean to enable or disable autosave. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //Rollbacks in mem the records that were edited and not yet saved. Best used in combination with autosave false.
databaseManager.setAutoSave(false)
//Now let users input data
//On save or cancel, when data has been entered:
if (cancel) databaseManager.rollbackEditedRecords()
databaseManager.setAutoSave(true) |
|
|
|
|
setCreateEmptyFormFoundsets() |
|
Turnoff the initial form foundset record loading, set this in the solution open method.
Simular to calling foundset.clear() in the form's onload event.
NOTE: When the foundset record loading is turned off, controller.find or controller.loadAllRecords must be called to display the records |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //this has to be called in the solution open method
databaseManager.setCreateEmptyFormFoundsets() |
|
|
|
|
Start a database transaction.
If you want to avoid round trips to the server or avoid the posibility of blocking other clients
because of your pending changes, you can use databaseManager.setAutoSave(false/true) and databaseManager.rollbackEditedRecords().
startTransaction, commit/rollbackTransacton() does support rollbacking of record deletes which autoSave = false doesnt support. |
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample // starts a database transaction
databaseManager.startTransaction()
//Now let users input data
//when data has been entered do a commit or rollback if the data entry is canceld or the the commit did fail.
if (cancel || !databaseManager.commitTransaction())
{
databaseManager.rollbackTransaction();
} |
|
|
|
|
switchServer(sourceName, destinationName) |
|
Switches a named server to another named server with the same datamodel (recommended to be used in an onOpen method for a solution).
return true if successful.
Note that this only works if source and destination server are of the same database type. |
|
|
Parameters The name of the source database server connection |
|
The name of the destination database server connection. |
|
|
|
|
Supported Clients SmartClient,WebClient,NGClient |
|
|
Sample //dynamically changes a server for the entire solution, destination database server must contain the same tables/columns!
//will fail if there is a lock, transaction , if repository_server is used or if destination server is invalid
//in the solution keep using the sourceName every where to reference the server!
var success = databaseManager.switchServer('crm', 'crm1') |
|
|
|
|
|
|