DocumentsModel extends CountModel, DeleteModel, ExistModel, GetModel, InsertModel, LastModel, ListModel, ReplaceModel, UpdateModel, UpsertModel, TruncateModel
Interface DocumentsModel
Defines a complete contract for managing documents in a storage system.
This interface groups together multiple CRUD-like operations and other database-related actions. It abstracts the logic for querying, inserting, updating, replacing, deleting, listing, truncating, and upserting documents in a storage backend (e.g., ArangoDB, OpenEdge SQL, etc.).
All inherited interfaces expose methods with a similar signature, accepting an optional $init
array of options and returning various types depending on the context.
Supported Operations:
- Counting documents.
- Checking existence of documents.
- Retrieving single or multiple documents.
- Inserting new documents.
- Updating or replacing existing documents.
- Upserting documents (insert or update depending on existence).
- Deleting documents.
- Listing documents based on criteria.
- Fetching the last document matching specific conditions.
- Truncating the underlying storage (removing all documents).
Tags
Table of Contents
Methods
- count() : int
- Returns the number of items in the model.
- delete() : null|array<string|int, mixed>|object
- Deletes an document or a set of documents in the model.
- exist() : bool
- Indicates if the passed-in item exist.
- get() : mixed
- Returns an item in the model.
- insert() : mixed
- Insert a new item into the model.
- last() : mixed
- Returns a the last document in the model.
- list() : array<string|int, mixed>
- Returns a collection of items in the model.
- replace() : mixed
- Replace a document into the model.
- truncate() : mixed
- Truncate the collection and remove all documents.
- update() : mixed
- Update an item into the model.
- upsert() : mixed
- Upsert a document into the collection.
Methods
count()
Returns the number of items in the model.
public
count([array<string|int, mixed> $init = [] ]) : int
Parameters
- $init : array<string|int, mixed> = []
Return values
intdelete()
Deletes an document or a set of documents in the model.
public
delete([array<string|int, mixed> $init = [] ]) : null|array<string|int, mixed>|object
Parameters
- $init : array<string|int, mixed> = []
Return values
null|array<string|int, mixed>|objectexist()
Indicates if the passed-in item exist.
public
exist([array<string|int, mixed> $init = [] ]) : bool
Parameters
- $init : array<string|int, mixed> = []
-
The optional setting definition.
Return values
bool —True of the value exist in the model.
get()
Returns an item in the model.
public
get([array<string|int, mixed> $init = [] ]) : mixed
Parameters
- $init : array<string|int, mixed> = []
insert()
Insert a new item into the model.
public
insert([array<string|int, mixed> $init = [] ]) : mixed
Parameters
- $init : array<string|int, mixed> = []
last()
Returns a the last document in the model.
public
last([array<string|int, mixed> $init = [] ]) : mixed
Parameters
- $init : array<string|int, mixed> = []
list()
Returns a collection of items in the model.
public
list([array<string|int, mixed> $init = [] ]) : array<string|int, mixed>
Parameters
- $init : array<string|int, mixed> = []
Return values
array<string|int, mixed>replace()
Replace a document into the model.
public
replace([array<string|int, mixed> $init = [] ]) : mixed
Parameters
- $init : array<string|int, mixed> = []
truncate()
Truncate the collection and remove all documents.
public
truncate([array<string|int, mixed> $init = [] ]) : mixed
Parameters
- $init : array<string|int, mixed> = []
update()
Update an item into the model.
public
update([array<string|int, mixed> $init = [] ]) : mixed
Parameters
- $init : array<string|int, mixed> = []
upsert()
Upsert a document into the collection.
public
upsert([array<string|int, mixed> $init = [] ]) : mixed
Parameters
- $init : array<string|int, mixed> = []