withOptions()
Helper function used to set payload
options on a single object or multiple object.
Basic usage
import { withOptions } from "@jjmyers/object-relationship-store";
const singleObject = { id: 1 }
const manyObjects = [{ id: 1 }, { id: 2 }]
// Setting payload options on a single object
withOptions(singleObject, {
__identify__: "user",
__destroy__: true
})
// Setting payload options on multiple objects
withOptions(manyObjects, {
__identify__: "user",
__destroy__: true
})
Properties
withOptions(object, options)
object
The object(s) you want to apply the payload on.
withOptions(object)
options
The payload
options you want applied on the object(s)
withOptions(object, {...payloadOptions})
Return values
const object = {id: 1};
const objectWithPayload = withOptions(object, { __identify__: "user", __destroy__: true });
store.mutate(objectWithPayload);
object with payload
The return value of withOptions()
is the object(s) with the payload applied on all of them. This payload can then be passed into store.mutate()
API
Properties
Property | Type | Default | Description |
---|---|---|---|
object | any | undefined | The object that you want to apply the payload options to. |
options | payload | undefined | The payload options for all objects. |
Return values
Returns the object(s) with the payload applied