JSDataSource
Methods Summary
Type | Name | Summary |
---|---|---|
Create a query builder for a data source.. | ||
Create a query builder for a data source with given table alias.. | ||
Get the column names of a datasource.. | ||
Get the datasource string.. | ||
Returns a foundset object for a specified datasource or server and tablename.. | ||
Returns a foundset object for a specified pk base query.. | ||
An existing foundset under that name will be returned, or created.. | ||
Get all currently foundsets for this datasource.. | ||
Get a single record from a datasource.. | ||
Get the table of a datasource.. | ||
get a new foundset containing records based on a dataset of pks.. | ||
get a new foundset containing records based on a QBSelect query that is given.. | ||
get a new foundset containing records based on an SQL query string.. | ||
get a new foundset containing records based on an SQL query string with parameters.. |
Methods Details
createSelect()
Create a query builder for a data source.
Returns QBSelect query builder
Sample
createSelect(tableAlias)
Create a query builder for a data source with given table alias. The alias can be used inside custom queries to bind to the outer table.
Parameters String tableAlias the table alias to use
Returns QBSelect query builder
Sample
getColumnNames()
Get the column names of a datasource.
Returns Array String[] column names
Sample
getDataSource()
Get the datasource string.
Returns String String datasource
Sample
getFoundSet()
Returns a foundset object for a specified datasource or server and tablename. It is important to note that this is a FACTORY method, it constantly creates new foundsets.
Returns JSFoundSet A new JSFoundset for the datasource.
Sample
getFoundSet(select)
Returns a foundset object for a specified pk base query. This creates a filtered "view" on top of the database table based on that query.
This foundset is different then when doing foundset.loadRecords(query) or datasources.db.server.table.loadRecords(query) because this is generated as a "view" Which means that the foundset will always have this query as its base, even when doing foundset.loadAllRecords() afterwards. Because this query is set as its "creation query" JSFoundset.loadRecords(query) does set that query on the current foundset as a a "search" condition. which will be removed when doing a loadAllRecords().
So doing a clear() on a foundse created by this call will just add a "search" condition that results in no records found ( 1 = 2) and then loadAllRecords() will go back to this query. But in a foundset.loadRecord(query) then clear() will overwrite the "search" condition which is the given query so the query will be lost after that so loadAllRecords() will go back to all records in the table)
Parameters QBSelect select The query to get the JSFoundset for.
Returns JSFoundSet A new JSFoundset with that query as its base query.
Sample
getFoundSet(name)
An existing foundset under that name will be returned, or created. If there is a definition (there is a form with a named foundset property with that name), the initial sort from that form will be used. If named foundset datasource does not match current datasource will not be returned (will return null instead).
Parameters String name The named foundset to get for this datasource.
Returns JSFoundSet An existing named foundset for the datasource.
Sample
getLoadedFoundSets()
Get all currently foundsets for this datasource. This method can be used to loop over foundset and programatically dispose them to clean up resources quickly.
Returns Array An array of foundsets loaded for this datasource.
Sample
getRecord(pk)
Get a single record from a datasource. For the sake of performance, if more records are needed, don't call this method in a loop but try using other methods instead.
Parameters Object pk The primary key of the record to be retrieved. Can be an array, in case of a composite pk.
Returns JSRecord a record
Sample
getTable()
Get the table of a datasource.
Returns JSTable JSTable table
Sample
loadRecords(dataSet)
get a new foundset containing records based on a dataset of pks.
Parameters JSDataSet dataSet ;
Returns JSFoundSet a new JSFoundset
Sample
loadRecords(qbSelect)
get a new foundset containing records based on a QBSelect query that is given.
This is just a shotcut for datasources.db.server.table.getFoundset() and then calling loadRecords(qbSelect) on the resulting foundset. So it has the same behavior as JSFoundset.loadRecords(qbselect) that is that the given query is set as a "search" condition on the existing query of the foundset. This means that if you do loadAllRecords() or calling clear() on it the qbselect conditon will also be removed. loadAllRecords() will revert back to the foundsets original query (see #getFoundSet(QBSelect) clear() will revert back to the original foundset query and add a "clear" condition to the query ( resulting in 1 = 2)
Parameters QBSelect qbSelect a query builder object
Returns JSFoundSet a new JSFoundset
Sample
loadRecords(query)
get a new foundset containing records based on an SQL query string.
Parameters String query an SQL query
Returns JSFoundSet a new JSFoundset
Sample
loadRecords(query, args)
get a new foundset containing records based on an SQL query string with parameters.
Parameters String query an SQL query string with parameter placeholders Array args an array of arguments for the query string
Returns JSFoundSet a new JSFoundset
Sample
Last updated