PHP Трейт Mongolid\Model\Relations

Показать файл Открыть проект

Открытые методы

Метод Описание
attach ( string $field, mixed &$obj ) : void Attach document _id reference to an attribute. It will also generate an _id for the document if it's not present.
detach ( string $field, mixed &$obj ) : void Removes a document _id reference from an attribute. It will remove the _id of the given $obj from inside the given $field.
embed ( string $field, mixed &$obj ) : void Embed a new document to an attribute. It will also generate an _id for the document if it's not present.
unembed ( string $field, mixed &$obj ) : void Removes an embedded document from the given field. It does that by using the _id of the given $obj.

Защищенные методы

Метод Описание
embedsMany ( string $entity, string $field ) : EmbeddedCursor Return array of embedded documents as objects.
embedsOne ( string $entity, string $field ) : Model | null Return a embedded documents as object.
referencesMany ( string $entity, string $field ) : array Returns the cursor for the referenced documents as objects.
referencesOne ( string $entity, string $field ) : mixed Returns the referenced documents as objects.

Описание методов

attach() публичный метод

Attach document _id reference to an attribute. It will also generate an _id for the document if it's not present.
public attach ( string $field, mixed &$obj ) : void
$field string Name of the field where the reference will be stored.
$obj mixed Document, model instance or _id to be referenced.
Результат void

detach() публичный метод

Removes a document _id reference from an attribute. It will remove the _id of the given $obj from inside the given $field.
public detach ( string $field, mixed &$obj ) : void
$field string Field where the reference is stored.
$obj mixed Document, model instance or _id that have been referenced by $field.
Результат void

embed() публичный метод

Embed a new document to an attribute. It will also generate an _id for the document if it's not present.
public embed ( string $field, mixed &$obj ) : void
$field string Field to where the $obj will be embedded.
$obj mixed Document or model instance.
Результат void

embedsMany() защищенный метод

Return array of embedded documents as objects.
protected embedsMany ( string $entity, string $field ) : EmbeddedCursor
$entity string Class of the entity or of the schema of the entity.
$field string Field where the embedded documents are stored.
Результат Mongolid\Cursor\EmbeddedCursor Array with the embedded documents

embedsOne() защищенный метод

Return a embedded documents as object.
protected embedsOne ( string $entity, string $field ) : Model | null
$entity string Class of the entity or of the schema of the entity.
$field string Field where the embedded document is stored.
Результат Model | null

referencesMany() защищенный метод

Returns the cursor for the referenced documents as objects.
protected referencesMany ( string $entity, string $field ) : array
$entity string Class of the entity or of the schema of the entity.
$field string The field where the _ids are stored.
Результат array

referencesOne() защищенный метод

Returns the referenced documents as objects.
protected referencesOne ( string $entity, string $field ) : mixed
$entity string Class of the entity or of the schema of the entity.
$field string The field where the _id is stored.
Результат mixed

unembed() публичный метод

Removes an embedded document from the given field. It does that by using the _id of the given $obj.
public unembed ( string $field, mixed &$obj ) : void
$field string Name of the field where the $obj is embeded.
$obj mixed Document, model instance or _id.
Результат void