A hook that is triggered before a find()
operation.
The beforeQuery()
hook runs when:
find
function is called.The hook also runs when an action is performed on a dataset that retrieves items from the collection that the dataset is connected to.
Return a query or a Promise that resolves to a query from the beforeQuery()
function. The returned query will be used as the query for the
find
operation.
Often, you will modify the query that is received in the query
parameter
by calling one or more WixDataQuery
functions.
If the returned value is of the wrong type, the value is ignored.
A rejected Promise blocks the call to find()
and also calls the onFailure()
hook if it has been registered.
Because the beforeQuery()
hook is called before find()
is executed, it can affect the query that is used to retrieve items
or block the find()
.
The original query as specified by the caller.
Contextual information about the hook.