A hook that is triggered after a find
operation, for each of the items in the query results.
The afterQuery()
hook runs when:
find
function is called.The hook runs once for each item in the collection.
Return an object or a Promise that resolves to an object from the afterQuery()
function. The returned object will be used as the result of the call to the
find
function instead of the actual item
found in the collection. If returning a Promise, the object is used as the
result, whether the Promise is fulfilled or rejected.
If the returned value is of the wrong type, the value is ignored.
A rejected Promise also calls the onFailure()
hook if it has
been registered.
Note:
We recommend implementing afterQuery()
with in-memory operations only. Don't use network calls such as REST API requests
or other wix-data operations, as these can lead to timeouts and issues loading collection data.
One of the items of the query result. The hook is called for each item in the results.
Contextual information about the hook.