Introduction
The WixDataQuery
functions enable you to run, sort, filter, and control
which results a query returns.
Typically, you build a query using the query()
function,
refine the query by chaining WixDataQuery
functions, and then execute the
query by chaining one of the following: find()
, distinct()
, or count()
For example, the following code queries a collection for all male customers over the age of 20 and logs the first 15 results to the console, sorted in ascending order by name:
javascript | Copy Codeimport wixData from 'wix-data';wixData.query("Customer").gt("age", 20).ascending("name").limit(15).find().then((results) => {console.log(results.items);});
When working with Wix app collections, fields in the collections have the following permissions:
- Can connect to data
- Can use in dynamic page URL
- Can be sorted
- Can be filtered
- Read-only
Check which fields can be used in a query.
Was this helpful?