Interface
QueriableDataSource extends DataSource and add query capability. A queriable data source must
have an URL to execute the query.
The current default query implementation supports pagination. It allows multiple widgets to apply queries on the same data source,
all of which are merged by using the AND logic operator.
When execute a query, in addition to the passed in query parameters, all configured queries and
all other widgets applied queries are merged by using the AND logic operator.
When a query is executed against a data view, the query from its main data source is used as well.
Properties
| Property | Type | Notes |
|---|---|---|
belongToDataSourceinherited | DataSource | The data source which this data source derives from. |
countinherited | number | The total records count depends on the current query |
dataSourceManagerinherited | DataSourceManager | The data source manager, which is used to manage the data source, including create/get/destroy the data source instance. |
dataViewIdinherited | string | The data view ID configured in JSON. |
idinherited | string | The data source ID. |
isDataViewinherited | boolean | True means the data source is a data view. For local data source, this is false even the local data source is created from a data view. |
isLocalinherited | boolean | True means the data source is a local data source. |
isSqlCaseSensitive | boolean | Whether the data source is case-sensitive when doing query by SQL clauses. |
localIdinherited | string | The local ID of the data source. |
orderinherited | number | Order in the parent data source. |
parentDataSourceinherited | DataSource & SetDataSourceMixin | The parent data source of this data source, mull means it's a root data source. |
typeinherited | string | The type of the data source. |
url | string | The data source URL |
Methods
| Method | Returns | Notes |
|---|---|---|
addSourceVersion()inherited | void | When current data source is created from an array of records, it will be saved in |
addVersion()inherited | void | Update data source version. |
buildRecord(data)inherited | DataRecord | Builds a data record only -- does not add the record into data source. |
clearRecords()inherited | void | This function will clear the loaded records and won't clear the sourceRecords. Once the loaded records are cleared, the version in the data source info will be updated. |
clearSourceRecords()inherited | void | Clear both sourceRecords and loaded records. Both source version and version in data source info will be updated. |
destroy()inherited | void | Destroy the data source. |
fetchSchema()inherited | Promise<IMDataSourceSchema> | Fetch the data schema from an actual data source. If it's a statistic data source, the schema will not be fetched. |
getAllDerivedDataSources()inherited | DataSource[] | Return the derived data views and local data sources. |
getAllLoadedRecords() | DataRecord[] | Get records of all the loaded pages. |
getAutoRefreshInterval() | number | If the return value > 0, auto refresh is enabled. |
getConfigQueryParams() | QueryParams | Get the user config query parameters. |
getCountStatus()inherited | DataSourceStatus | Return data source count status. |
getCurrentQueryId() | string | Get the current loaded record id, which is used in |
getCurrentQueryParams(options?) | QueryParams | Get the current query parameters. The current query parameters contain all applied queries. |
getDataSourceJson()inherited | IMDataSourceJson | The data source JSON object in app config. |
getDataView(dataViewId) | QueriableDataSource | Get data view by data view ID. |
getDataViewConfig()inherited | IMDataViewJson | Return the config of the current data source. |
getDataViews() | QueriableDataSource[] | Override parent interface to get correct type. |
getIdField()inherited | string | Return the data source ID field. |
getInfo()inherited | IMDataSourceInfo | Return the data source info in redux store. |
getLabel()inherited | string | Return data source label. |
getListenSelection()inherited | boolean | Return whether listen selection. |
getLocalDataSource(localId)inherited | DataSource | Get local data source by local ID. |
getLocalDataSources()inherited | DataSource[] | Return all local data sources created from a main data source or data view. |
getMainDataSource() | QueriableDataSource | Return the main data source. |
getMaxRecordCount() | number | Null means there is no record count limit, and will return all records from the service. |
getRealQueryPages(pageSize, page) | number[] | Get real query page depends on the widget's request page. |
getRealQueryParams(query, flag, options?) | QueryParams | When do query/load, we do not fire the query request directly. Instead, we'll consider the data source's config/current query parameter. |
getRecordById(id)inherited | DataRecord | Get record by ID |
getRecords() | DataRecord[] | Get records of the loaded continuous pages. If the loaded pages are 1, 2, and 10, will only return records on the page 1 and 2. |
getRecordsByPage(page, pageSize) | DataRecord[] | The page size here defines the records this method returns, which are not the actual query pageSize. Will use a fixed pageSize to query and cache data. |
getRecordsByPageWithSelection(page, pageSize) | DataRecord[] | If selected records are not loaded in the current data source, will concat them to the end of records array. See getRecordsWithSelection for details. |
getRecordsWithSelection()inherited | DataRecord[] | If selected records are not loaded in the current data source, they will be concatenated to the end of records array. For example, record 1 is selected in data view 1 and it is not loaded in data view 2 (record 1 actually matches query params of data view 2), dataView2.getRecordsWithSelection() will return all loaded records in data view 2 and record 1. |
getRemoteQueryParams() | QueryParams | Get the query parameters configured in remote (not in exb). |
getRootDataSource()inherited | DataSource | Return the root data source. |
getRuntimeQueryParams(excludeWidgetId?) | QueryParams | Get the queries applied in runtime. If the excludeWidgetId is passed in, the queries of this widget will be excluded. |
getSchema()inherited | IMDataSourceSchema | The schema returned here is the merged result of the configured schema and the fetched schema. The configured schema is the user's changes, such as a new data source name. The fetched schema is the original schema from AGOL/portal item or a remote database, such as the service name, the fields and the filters. |
getSelectedRecordIds()inherited | string[] | Get selected record IDs |
getSelectedRecordIndexes()inherited | number[] | Get selected record indexes |
getSelectedRecords()inherited | DataRecord[] | Get selected records |
getSelectionDataView()inherited | DataSource | Get selection data view |
getSourceRecords()inherited | DataRecord[] | Return the source records |
getSourceVersion()inherited | number | When current data source is created from an array of records, it will be saved in |
getStatus()inherited | DataSourceStatus | Return data source status. |
getVersion()inherited | number | Return data source version. |
isDataSourceSet()inherited | thisisDataSource & SetDataSourceMixin | Whether a data source contains child data sources.
A set data source won't create all its child data sources when |
isInAppConfig()inherited | boolean | Return whether the data source is added in builder and is saved in app config. |
isSelectionView()inherited | boolean | Determine whether the data source is a selection view. |
load(query, options?) | Promise<DataRecord[]> | Execute the query against the service and update the internal data records, pagination is supported.
When call this method, the real query is returned by |
loadAll(query, signal?, progressCallback?, options?) | Promise<DataRecord[]> | Load all records, there is no limit to the number of the records returned in the |
loadById(id, refresh?) | Promise<DataRecord> | Load record by ID, do not consider other queries. |
loadCount(query, options?) | Promise<number> | Load the records count. |
mergeQueryParams(queries) | QueryParams | Merge queries by using |
query(query, options?) | Promise<QueryResult> | Execute query against the service only, do NOT update the internal data records.
The actual query parameters are generated by |
queryAll(query, signal?, progressCallback?, options?) | Promise<QueryResult> | Query all records, there is no limit to the number of the records returned in the |
queryById(id, fields?) | Promise<DataRecord> | Query record by ID.
Will return all fields if not pass in the |
queryCount(query, options?) | Promise<QueryResult> | Query count |
queryIds(query, options?) | Promise<QueryResult> | Query record IDs, there is no limit to the number of the IDs returned in the |
ready()inherited | Promise<any> | Ready is resolved means the data source instance is ready for use.
Please note that can not make sure all child data sources are created if a set data source is ready.
To make sure all child data sources are created, please use |
selectAllLoadedRecords() | void | Select all loaded records. |
selectRecordById(id, record?)inherited | void | Select a record by ID. When select record by ID, we can pass in the record. So when the selected record is not loaded, we can add it in. |
selectRecords(options, signal?, progressCallback?) | Promise<QueryResult> | Select records. |
selectRecordsByIds(ids, records?)inherited | void | Select records by IDs. When select records by IDs, we can pass in the records. So when the selected records are not loaded, we can add them in. |
setCountStatus(status)inherited | void | Update data source count status. |
setDataSourceJson(dsJson)inherited | void | Update data source JSON in data source instance |
setListenSelection(listen)inherited | void | Whether listen selected records from other data sources which are derived from the same main data source. If true, will update selected record IDs of current data source info when selecting records via other derived data sources. Will also update selected record IDs when selecting records via current data source itself. If false, won't change selected record IDs when selecting records via other derived data sources. Will update selected record IDs only when selecting records via current data source itself. |
setNeedRefresh(needRefresh) | void | When the auto refresh is turned on, and the data source needRefresh status is changed, this method will be invoked. |
setRecords(records)inherited | void | Update the records in the data source object only, does not update the source data. |
setSourceRecords(records)inherited | void | When current data source is created from an array of records, will save it in |
setStatus(status)inherited | void | Update data source status. |
updateQueryParams(query, widgetId) | void | Update the data source query without executing the actual query. |
updateSelectionInfo(options, triggerDataSource, forceCheck?)inherited | void | Update selected records in data source info if the current data source listens selection change (see |
addSourceVersion
addSourceVersion(): voidWhen current data source is created from an array of records, it will be saved in sourceRecords .
Add the version of sourceRecords .
setSourceRecords will add the version by default.
Returns
voidaddVersion
addVersion(): voidUpdate data source version.
Returns
voidbuildRecord
buildRecord(data: any): DataRecordBuilds a data record only -- does not add the record into data source.
Parameters
| Parameter | Type |
|---|---|
data | any |
Returns
DataRecordclearRecords
clearRecords(): voidThis function will clear the loaded records and won't clear the sourceRecords. Once the loaded records are cleared, the version in the data source info will be updated.
Returns
voidclearSourceRecords
clearSourceRecords(): voidClear both sourceRecords and loaded records. Both source version and version in data source info will be updated.
Returns
voidfetchSchema
fetchSchema(): Promise<IMDataSourceSchema>Fetch the data schema from an actual data source. If it's a statistic data source, the schema will not be fetched.
Returns
Promise<IMDataSourceSchema>getAllDerivedDataSources
getAllDerivedDataSources(): DataSource[]Return the derived data views and local data sources.
Returns
DataSource[]getAllLoadedRecords
Interface MethodgetAllLoadedRecords(): DataRecord[]Get records of all the loaded pages.
Returns
DataRecord[]getAutoRefreshInterval
Interface MethodgetAutoRefreshInterval(): numberIf the return value > 0, auto refresh is enabled.
Returns
numbergetConfigQueryParams
Interface MethodgetConfigQueryParams(): QueryParamsGet the user config query parameters.
Returns
QueryParamsgetCountStatus
getCountStatus(): DataSourceStatusReturn data source count status.
Returns
DataSourceStatusgetCurrentQueryId
Interface MethodgetCurrentQueryId(): stringGet the current loaded record id, which is used in loadById method.
Returns
stringgetCurrentQueryParams
Interface MethodgetCurrentQueryParams(options?: GetCurrentQueryParamsOptions): QueryParamsGet the current query parameters. The current query parameters contain all applied queries.
Parameters
| Parameter | Type |
|---|---|
options | GetCurrentQueryParamsOptions |
Returns
QueryParamsgetDataSourceJson
getDataSourceJson(): IMDataSourceJsonThe data source JSON object in app config.
Returns
IMDataSourceJsongetDataView
Interface MethodgetDataView(dataViewId: string): QueriableDataSourceGet data view by data view ID.
Parameters
| Parameter | Type |
|---|---|
data | string |
Returns
QueriableDataSourcegetDataViewConfig
getDataViewConfig(): IMDataViewJsonReturn the config of the current data source.
Returns
IMDataViewJsongetDataViews
Interface MethodgetDataViews(): QueriableDataSource[]Override parent interface to get correct type.
Returns
QueriableDataSource[]getIdField
getIdField(): stringReturn the data source ID field.
Returns
stringgetInfo
getInfo(): IMDataSourceInfoReturn the data source info in redux store.
Returns
IMDataSourceInfogetListenSelection
getListenSelection(): booleanReturn whether listen selection.
Returns
booleangetLocalDataSource
getLocalDataSource(localId: string): DataSourceGet local data source by local ID.
Parameters
| Parameter | Type |
|---|---|
local | string |
Returns
DataSourcegetLocalDataSources
getLocalDataSources(): DataSource[]Return all local data sources created from a main data source or data view.
Returns
DataSource[]getMainDataSource
Interface MethodgetMainDataSource(): QueriableDataSourceReturn the main data source.
Returns
QueriableDataSourcegetMaxRecordCount
Interface MethodgetMaxRecordCount(): numberNull means there is no record count limit, and will return all records from the service.
Returns
numbergetRealQueryPages
Interface MethodgetRealQueryPages(pageSize: number, page: number): number[]Get real query page depends on the widget's request page.
Parameters
| Parameter | Type |
|---|---|
page | number |
page | number |
Returns
number[]getRealQueryParams
Interface MethodgetRealQueryParams(query: QueryParams, flag: "load" | "query", options?: QueryOptions): QueryParamsWhen do query/load, we do not fire the query request directly. Instead, we'll consider the data source's config/current query parameter.
- For load: we'll merge the configured query parameter if it has, and all widget applied queries.
- For query, we'll merge the current query parameter and the configured query parameter it has.
Parameters
| Parameter | Type |
|---|---|
query | QueryParams |
flag | "load" | "query" |
options | QueryOptions |
Returns
QueryParamsgetRecordById
getRecordById(id: string): DataRecordGet record by ID
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
DataRecordgetRecords
Interface MethodgetRecords(): DataRecord[]Get records of the loaded continuous pages. If the loaded pages are 1, 2, and 10, will only return records on the page 1 and 2.
Widgets can use different page sizes to query the data source, but the data source has a specific page size to query the service. The data source will save the loaded records by its own page size and split them when widgets doing queries (with different page and page sizes). The method returns continuous page records to make sure the order of the records is correct.
Returns
DataRecord[]getRecordsByPage
Interface MethodgetRecordsByPage(page: number, pageSize: number): DataRecord[]The page size here defines the records this method returns, which are not the actual query pageSize. Will use a fixed pageSize to query and cache data.
Parameters
| Parameter | Type |
|---|---|
page | number |
page | number |
Returns
DataRecord[]getRecordsByPageWithSelection
Interface MethodgetRecordsByPageWithSelection(page: number, pageSize: number): DataRecord[]If selected records are not loaded in the current data source, will concat them to the end of records array. See getRecordsWithSelection for details.
Parameters
| Parameter | Type |
|---|---|
page | number |
page | number |
Returns
DataRecord[]getRecordsWithSelection
getRecordsWithSelection(): DataRecord[]If selected records are not loaded in the current data source, they will be concatenated to the end of records array. For example, record 1 is selected in data view 1 and it is not loaded in data view 2 (record 1 actually matches query params of data view 2), dataView2.getRecordsWithSelection() will return all loaded records in data view 2 and record 1.
Returns
DataRecord[]getRemoteQueryParams
Interface MethodgetRemoteQueryParams(): QueryParamsGet the query parameters configured in remote (not in exb).
Returns
QueryParamsgetRootDataSource
getRootDataSource(): DataSourceReturn the root data source.
Returns
DataSourcegetRuntimeQueryParams
Interface MethodgetRuntimeQueryParams(excludeWidgetId?: string): QueryParamsGet the queries applied in runtime. If the excludeWidgetId is passed in, the queries of this widget will be excluded.
Parameters
| Parameter | Type |
|---|---|
exclude | string |
Returns
QueryParamsgetSchema
getSchema(): IMDataSourceSchemaThe schema returned here is the merged result of the configured schema and the fetched schema. The configured schema is the user's changes, such as a new data source name. The fetched schema is the original schema from AGOL/portal item or a remote database, such as the service name, the fields and the filters.
Returns
IMDataSourceSchemagetSelectedRecordIds
getSelectedRecordIds(): string[]Get selected record IDs
Returns
string[]getSelectedRecordIndexes
getSelectedRecordIndexes(): number[]Get selected record indexes
Returns
number[]getSelectedRecords
getSelectedRecords(): DataRecord[]Get selected records
Returns
DataRecord[]getSelectionDataView
getSelectionDataView(): DataSourceGet selection data view
Returns
DataSourcegetSourceRecords
getSourceRecords(): DataRecord[]Return the source records
Returns
DataRecord[]getSourceVersion
getSourceVersion(): numberWhen current data source is created from an array of records, it will be saved in sourceRecords .
Return the version of sourceRecords .
Returns
numbergetStatus
getStatus(): DataSourceStatusReturn data source status.
Returns
DataSourceStatusgetVersion
getVersion(): numberReturn data source version.
Returns
numberisDataSourceSet
isDataSourceSet(): thisisDataSource & SetDataSourceMixinWhether a data source contains child data sources.
A set data source won't create all its child data sources when ready is resolved.
To make sure all child data sources are created, please use childDataSourcesReady .
Returns
thisisDataSource & SetDataSourceMixinisInAppConfig
isInAppConfig(): booleanReturn whether the data source is added in builder and is saved in app config.
Returns
booleanisSelectionView
isSelectionView(): booleanDetermine whether the data source is a selection view.
Returns
booleanload
Interface Methodload(query: QueryParams, options?: QueryOptions): Promise<DataRecord[]>Execute the query against the service and update the internal data records, pagination is supported.
When call this method, the real query is returned by getRealQueryParams .
Pagination: The pagination properties in the passed in query parameter may be not the same as the real query pagination that is sent to the service. The real query pagination is defined in the data source setting.
Parameters
| Parameter | Type |
|---|---|
query | QueryParams |
options | QueryOptions |
Returns
Promise<DataRecord[]>loadAll
Interface MethodloadAll(query: QueryParams, signal?: AbortSignal, progressCallback?: QueryProgressCallback, options?: QueryOptions): Promise<DataRecord[]>Load all records, there is no limit to the number of the records returned in the records array response.
You can abort the progress by a abort signal and can use progressCallback to get the progress and the current results.
Parameters
| Parameter | Type |
|---|---|
query | QueryParams |
signal | AbortSignal |
progress | QueryProgressCallback |
options | QueryOptions |
Returns
Promise<DataRecord[]>loadById
Interface MethodloadById(id: string, refresh?: boolean): Promise<DataRecord>Load record by ID, do not consider other queries.
Parameters
| Parameter | Type |
|---|---|
id | string |
refresh | boolean |
Returns
Promise<DataRecord>loadCount
Interface MethodloadCount(query: QueryParams, options?: QueryOptions): Promise<number>Load the records count.
Parameters
| Parameter | Type |
|---|---|
query | QueryParams |
options | QueryOptions |
Returns
Promise<number>mergeQueryParams
Interface MethodmergeQueryParams(queries: QueryParams[]): QueryParamsMerge queries by using AND , and return the merged result.
If any query is undefined/null, it will be ignored.
Parameters
| Parameter | Type |
|---|---|
queries | QueryParams[] |
Returns
QueryParamsquery
Interface Methodquery(query: QueryParams, options?: QueryOptions): Promise<QueryResult>Execute query against the service only, do NOT update the internal data records.
The actual query parameters are generated by getRealQueryParams .
To query count, please use queryCount .
Parameters
| Parameter | Type |
|---|---|
query | QueryParams |
options | QueryOptions |
Returns
Promise<QueryResult>queryAll
Interface MethodqueryAll(query: QueryParams, signal?: AbortSignal, progressCallback?: QueryProgressCallback, options?: QueryOptions): Promise<QueryResult>Query all records, there is no limit to the number of the records returned in the records array response.
You can abort the progress by a abort signal and can use progressCallback to get the progress and the current results.
Parameters
| Parameter | Type |
|---|---|
query | QueryParams |
signal | AbortSignal |
progress | QueryProgressCallback |
options | QueryOptions |
Returns
Promise<QueryResult>queryById
Interface MethodqueryById(id: string, fields?: string[]): Promise<DataRecord>Query record by ID.
Will return all fields if not pass in the fields .
Parameters
| Parameter | Type |
|---|---|
id | string |
fields | string[] |
Returns
Promise<DataRecord>queryCount
Interface MethodqueryCount(query: QueryParams, options?: QueryOptions): Promise<QueryResult>Query count
Parameters
| Parameter | Type |
|---|---|
query | QueryParams |
options | QueryOptions |
Returns
Promise<QueryResult>queryIds
Interface MethodqueryIds(query: QueryParams, options?: QueryOptions): Promise<QueryResult>Query record IDs, there is no limit to the number of the IDs returned in the ids array response.
Parameters
| Parameter | Type |
|---|---|
query | QueryParams |
options | QueryOptions |
Returns
Promise<QueryResult>ready
ready(): Promise<any>Ready is resolved means the data source instance is ready for use.
Please note that can not make sure all child data sources are created if a set data source is ready.
To make sure all child data sources are created, please use childDataSourcesReady .
Returns
Promise<any>selectAllLoadedRecords
Interface MethodselectAllLoadedRecords(): voidSelect all loaded records.
Returns
voidselectRecordById
selectRecordById(id: string, record?: DataRecord): voidSelect a record by ID. When select record by ID, we can pass in the record. So when the selected record is not loaded, we can add it in.
Parameters
| Parameter | Type | Notes |
|---|---|---|
id | string | The ID to be selected. The selection will be cleared if the ID is null. |
record | DataRecord |
Returns
voidselectRecords
Interface MethodselectRecords(options: QueriableSelectOptions, signal?: AbortSignal, progressCallback?: QueryProgressCallback): Promise<QueryResult>Select records.
Parameters
| Parameter | Type |
|---|---|
options | QueriableSelectOptions |
signal | AbortSignal |
progress | QueryProgressCallback |
Returns
Promise<QueryResult>selectRecordsByIds
selectRecordsByIds(ids: string[], records?: DataRecord[]): voidSelect records by IDs. When select records by IDs, we can pass in the records. So when the selected records are not loaded, we can add them in.
Parameters
| Parameter | Type | Notes |
|---|---|---|
ids | string[] | The IDs to be selected. The selection will be cleared if the IDs are null. |
records | DataRecord[] |
Returns
voidsetCountStatus
setCountStatus(status: DataSourceStatus): voidUpdate data source count status.
Parameters
| Parameter | Type |
|---|---|
status | DataSourceStatus |
Returns
voidsetDataSourceJson
setDataSourceJson(dsJson: IMDataSourceJson): voidUpdate data source JSON in data source instance
Parameters
| Parameter | Type |
|---|---|
ds | IMDataSourceJson |
Returns
voidsetListenSelection
setListenSelection(listen: boolean): voidWhether listen selected records from other data sources which are derived from the same main data source. If true, will update selected record IDs of current data source info when selecting records via other derived data sources. Will also update selected record IDs when selecting records via current data source itself. If false, won't change selected record IDs when selecting records via other derived data sources. Will update selected record IDs only when selecting records via current data source itself.
Main data source and its data views will listen selected records by default, local data source does not listen selected records by default.
Parameters
| Parameter | Type |
|---|---|
listen | boolean |
Returns
voidsetNeedRefresh
Interface MethodsetNeedRefresh(needRefresh: boolean): voidWhen the auto refresh is turned on, and the data source needRefresh status is changed, this method will be invoked.
Parameters
| Parameter | Type |
|---|---|
need | boolean |
Returns
voidsetRecords
setRecords(records: DataRecord[]): voidUpdate the records in the data source object only, does not update the source data.
Parameters
| Parameter | Type |
|---|---|
records | DataRecord[] |
Returns
voidsetSourceRecords
setSourceRecords(records: DataRecord[]): voidWhen current data source is created from an array of records, will save it in sourceRecords .
These two methods are used to update or get the source data.
Parameters
| Parameter | Type |
|---|---|
records | DataRecord[] |
Returns
voidsetStatus
setStatus(status: DataSourceStatus): voidUpdate data source status.
Parameters
| Parameter | Type |
|---|---|
status | DataSourceStatus |
Returns
voidupdateQueryParams
Interface MethodupdateQueryParams(query: QueryParams, widgetId: string): voidUpdate the data source query without executing the actual query.
Parameters
| Parameter | Type |
|---|---|
query | QueryParams |
widget | string |
Returns
voidupdateSelectionInfo
updateSelectionInfo(options: SelectOptions, triggerDataSource: DataSource, forceCheck?: boolean): voidUpdate selected records in data source info if the current data source listens selection change (see setListenSelection ) or the current data source is the trigger data source (that is to say, select via it).
Before update info, will check whether these selected records match filters of the current data source firstly, and then only set the matched selected records to info.
Will skip the check in some cases to improve performance if the forceCheck is not passed in or is false. For example, if the current data source is main data source (we suppose that main data source contains all records, no need to check).
But if the forceCheck is true, won't skip the check.
Parameters
| Parameter | Type |
|---|---|
options | SelectOptions |
trigger | DataSource |
force | boolean |
Returns
void