Methods
-
getItems()
-
Returns:
A snapshot of items matching current query expression. -
<async> search(queryExpression)
-
Spawns a new search request. The result will be provided asynchronously via the InstantQuery#event:searchResult event.
Parameters:
Name Type Description queryExpression
String A query expression to be executed against the given data index. For more information on the syntax read Client#liveQuery. Returns:
A promise that resolves when query result has been received.- Type
- Promise.<void>
-
<async> subscribe()
-
Instantiates a LiveQuery object based on the last known query expression that was passed to the InstantQuery#search method. This LiveQuery will start receiving updates with new results, while current object can be still used to execute repetitive searches.
Returns:
A promise which resolves when the LiveQuery object is ready.- Type
- Promise.<LiveQuery>
-
updateIndexName(indexName)
-
Set new index name
Parameters:
Name Type Description indexName
String New index name to set Returns:
void
Events
-
searchResult
-
Fired when a search result is ready.
Parameters:
Name Type Description items
LiveQuery#ItemsSnapshot A snapshot of items matching current query expression. Example
instantQuery.on('searchResult', function(items) { Object.entries(items).forEach(([key, value]) => { console.log('Search result item key: ' + key); console.log('Search result item value: ' + value); }); });