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 query() method builds a query to retrieve data items from a collection and returns a WixDataQuery object, which contains the query definition. You can refine the query by chaining WixDataQuery methods onto the query. WixDataQuery methods enable you to sort, filter, and control the query results.
The methods chained to query() are applied in the order they are called. For example, if you sort by an age field in ascending order and then by a name field in descending order, the results are sorted first by the age of the items. If there are multiple results with the same age, they are further sorted by name in descending order, per age value.
Finally, to run the query, chain find() or distinct() as the last method.
The query() method runs with the following WixDataQuery defaults that you can override:
skip: 0limit: 50descending: by _createdDateinclude: noneNotes:
query() immediately following an update to your collection, the data retrieved might not contain the most recent changes. If you need the most up-to-date data, set the options.consistentRead parameter of the find() or distinct() methods to true. Learn more about Wix Data and eventual consistency.include() method.ID of the collection to run the query on.
This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.