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;
});
Refines a query to match items whose specified property value is greater than or equal to the specified value.
The ge()
function refines an EventsQueryBuilder
to only
match items where the value of the specified property is greater than or equal to the specified value
.
It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.
If a property contains a number as a String, that value will be compared alphabetically and not numerically. Items that do not have a value for the specified property are ranked lowest.
The following types of properties can be compared:
"abc"
is greater than or equal to "ABC"
(because of the greater than),
but "ABC"
is not greater than or equal to "abc"
function ge(propertyName: string, value: union): EventsQueryBuilder;
The property whose value will be compared with value
.
Supported properties:
scheduling.startDate
scheduling.endDate
title
slug
The value to match against.
const query = wixEvents
.queryEvents()
.ge("_updatedDate", "2020-04-27T10:00:00.000Z");