UpsertModel
Contract for models able to upsert a document.
An UpsertModel exposes a single UpsertModel::upsert() operation that
inserts a document when it does not yet exist, or updates/replaces it when it
does. It is the idempotent way to persist a document without first probing for
its existence.
Tags
Table of Contents
Methods
- upsert() : mixed
- Inserts or updates a document depending on whether it already exists.
Methods
upsert()
Inserts or updates a document depending on whether it already exists.
public
upsert([array<string|int, mixed> $init = [] ]) : mixed
Parameters
- $init : array<string|int, mixed> = []
-
Operation options carrying the document and its lookup keys, typically the matching
conditions/key, thedocumentpayload, optionalbindsand a return clause.
Tags
Return values
mixed —The upserted document (or its result), depending on the implementation.