Returns the items that match the query.
The find()
function returns a Promise that resolves to the results found
by the query and some information about the results. The Promise is
rejected if find()
is called with incorrect permissions or if any of the
functions used to refine the query are invalid.
Note: A guest can only view their own events. You can override the permissions by setting the suppressAuth
option to true
.
function find(options: QueryOptions): Promise<EventsQueryResult>;
Options to use when performing a query or query count.
import { wixEvents } from "wix-events-backend";
// ...
wixEvents
.queryEvents()
.find()
.then((results) => {
if (results.items.length > 0) {
const items = results.items;
const firstItem = items[0];
const totalCount = results.totalCount;
const pageSize = results.pageSize;
const currentPage = results.currentPage;
const totalPages = results.totalPages;
const hasNext = results.hasNext();
const hasPrev = results.hasPrev();
const length = results.length;
const query = results.query;
} else {
// handle case where no matching items found
}
})
.catch((error) => {
const queryError = error;
});
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.