Property | Type | Description | |
---|---|---|---|
$schemaClass | string | Name of the schema class to be used. |
Property | Type | Description | |
---|---|---|---|
$assembler | Have the responsibility of assembling the data coming from the database into actual entities. | ||
$connPool | Connections that are going to be used to interact with the database. | ||
$eventService | In order to dispatch events when necessary. | ||
$schema | Schema object. Will be set after the $schemaClass. |
Method | Description | |
---|---|---|
__construct ( |
||
all ( ) : |
Retrieve a database cursor that will return all documents as $this->schema->entityClass objects upon iteration. | |
delete ( mixed $entity, array $options = [] ) : boolean | Removes the given document from the collection. | |
first ( mixed $query = [], array $projection = [], boolean $cacheable = false ) : mixed | Retrieve one $this->schema->entityClass objects that matches the given query. | |
firstOrFail ( mixed $query = [], array $projection = [], boolean $cacheable = false ) : mixed | Retrieve one $this->schema->entityClass objects that matches the given query. If no document was found, throws ModelNotFoundException. | |
getSchema ( ) : |
||
insert ( mixed $entity, array $options = [], boolean $fireEvents = true ) : boolean | Inserts the given object into database. Returns success if write concern is acknowledged. Since it's an insert, it will fail if the _id already exists. | |
save ( mixed $entity, array $options = [] ) : boolean | Upserts the given object into database. Returns success if write concern is acknowledged. | |
setSchema ( |
Set a Schema object that describes an Entity in MongoDB. | |
update ( mixed $entity, array $options = [] ) : boolean | Updates the given object into database. Returns success if write concern is acknowledged. Since it's an update, it will fail if the document with the given _id did not exists. | |
where ( mixed $query = [], array $projection = [], boolean $cacheable = false ) : |
Retrieve a database cursor that will return $this->schema->entityClass objects that upon iteration. |
Method | Description | |
---|---|---|
fireEvent ( string $event, mixed $entity, boolean $halt = false ) : mixed | Triggers an event. May return if that event had success. | |
getAssembler ( ) : |
Retrieves an EntityAssembler instance. | |
getCollection ( ) : MongoDB\Collection | Retrieves the Collection object. | |
getSchemaMapper ( ) : |
Returns a SchemaMapper with the $schema or $schemaClass instance. | |
parseToDocument ( mixed $entity ) : array | Parses an object with SchemaMapper and the given Schema. | |
prepareArrayFieldOfQuery ( array $value ) : array | Prepares an embedded array of an query. It will convert string ObjectIDs in operators into actual objects. | |
prepareProjection ( array $fields ) : array | Converts the given projection fields to Mongo driver format. | |
prepareValueQuery ( mixed $value ) : array | Transforms a value that is not an array into an MongoDB query (array). |
Method | Description | |
---|---|---|
afterSuccess ( mixed $entity ) | Perform actions on object before firing the after event. | |
mergeOptions ( array $defaultOptions = [], array $toMergeOptions = [] ) : array | Merge all options. |
public __construct ( |
||
$connPool | The connections that are going to be used to interact with the database. |
public all ( ) : |
||
return |
public first ( mixed $query = [], array $projection = [], boolean $cacheable = false ) : mixed | ||
$query | mixed | MongoDB query to retrieve the document. |
$projection | array | Fields to project in Mongo query. |
$cacheable | boolean | Retrieves the first through a CacheableCursor. |
return | mixed | First document matching query as an $this->schema->entityClass object |
public firstOrFail ( mixed $query = [], array $projection = [], boolean $cacheable = false ) : mixed | ||
$query | mixed | MongoDB query to retrieve the document. |
$projection | array | Fields to project in Mongo query. |
$cacheable | boolean | Retrieves the first through a CacheableCursor. |
return | mixed | First document matching query as an $this->schema->entityClass object |
protected getAssembler ( ) : |
||
return |
protected getCollection ( ) : MongoDB\Collection | ||
return | MongoDB\Collection |
protected getSchemaMapper ( ) : |
||
return |
public insert ( mixed $entity, array $options = [], boolean $fireEvents = true ) : boolean | ||
$entity | mixed | The entity used in the operation. |
$options | array | Possible options to send to mongo driver. |
$fireEvents | boolean | Whether events should be fired. |
return | boolean | Success (but always false if write concern is Unacknowledged) |
protected parseToDocument ( mixed $entity ) : array | ||
$entity | mixed | The object to be parsed. |
return | array | Document |
protected prepareArrayFieldOfQuery ( array $value ) : array | ||
$value | array | Array that will be treated. |
return | array | Prepared array. |
protected prepareProjection ( array $fields ) : array | ||
$fields | array | Fields to project. |
return | array |
protected prepareValueQuery ( mixed $value ) : array | ||
$value | mixed | The _id of the document. |
return | array | Query for the given _id |
public setSchema ( |
||
$schema |
protected EntityAssembler,Mongolid\DataMapper $assembler | ||
return |
protected Pool,Mongolid\Connection $connPool | ||
return |
protected EventTriggerService,Mongolid\Event $eventService | ||
return |
protected Schema,Mongolid\Schema $schema | ||
return |
public string $schemaClass | ||
return | string |