queryDataItems( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a query to retrieve items from a database collection.

The queryDataItems() function builds a query to retrieve data items from a collection and returns a DataItemsQueryBuilder object.

The returned object contains the query definition which is typically used to run the query using the find() function.

You can refine the query by chaining DataItemsQueryBuilder functions onto the query. DataItemsQueryBuilder functions enable you to sort, filter, and control the results that queryDataItems() returns.

The queryDataItems() function runs with the following DataItemsQueryBuilder defaults that you can override:

  • skip: 0
  • limit: 50
  • descending: by _createdDate

The functions that are chained to queryDataItems() are applied in the order they are called. For example, if you sort on an age field in ascending order and then on a name field in descending order, the results are sorted first by the age of the items and then, if there are multiple results with the same age, the items are sorted by name in descending order, per age value.

If the collection that you are querying has references to other collections, by default the data from referenced collections is not retrieved. To get the data from referenced items, specify them in the options.includeReferencedItems parameter.

Note: When calling queryDataItems() following an update to your collection, the data retrieved may not contain the most recent changes. If you need the most up-to-date data, set options.consistentRead to true.

Permission Scopes

For app development, you must have one of the following permission scopes:
Read Data Items
Learn more about permission scopes.
Method Declaration
Method Parameters

Options for querying data items.

Was this helpful?