PHP Trait Mongolid\Model\Relations

Afficher le fichier Open project: leroy-merlin-br/mongolid

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
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.

Method Details

attach() public méthode

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.
Résultat void

detach() public méthode

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.
Résultat void

embed() public méthode

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.
Résultat void

embedsMany() protected méthode

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.
Résultat Mongolid\Cursor\EmbeddedCursor Array with the embedded documents

embedsOne() protected méthode

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.
Résultat Model | null

referencesMany() protected méthode

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.
Résultat array

referencesOne() protected méthode

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.
Résultat mixed

unembed() public méthode

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.
Résultat void