A hook that is triggered before a get()
operation.
The beforeGet()
hook runs when the get()
function is called.
The hook does not run when the find
function is called or when a dataset retrieves items from the collection it
is connected to.
Return a string or a Promise that resolves to a string from the beforeGet()
function. The returned string will be used as the itemId
parameter for the
get()
operation. The item with the new itemId
will
be retrieved instead of the item with the original itemId
.
If the returned value is of the wrong type, the value is ignored.
A rejected Promise blocks the call to get()
and also calls the onFailure()
hook if it has been registered.
Because the beforeGet()
hook is called before get()
is executed, it can affect which item is retrieved
or block the get()
.
The ID of the original item to be retrieved.
Contextual information about the hook.