PHP Class Mongolid\Schema\Schema

Show file Open project: leroy-merlin-br/mongolid

Public Properties

Property Type Description
$collection string Name of the collection where this kind of document is going to be saved or retrieved from.
$dynamic boolean The $dynamic property tells if the schema will accept additional fields that are not specified in the $fields property. This is useful if you does not have a strict document format or if you want to take full advantage of the "schemaless" nature of MongoDB.
$entityClass string Name of the class that will be used to represent a document of this Schema when retrieve from the database.
$fields string[] The last option is to define a field as another schema by using the syntax 'schema.' This represents an embedded document (or sub-document).

Public Methods

Method Description
createdAtTimestamp ( mixed | null $value ) : UTCDateTime Prepares the field to be the datetime that the document has been created.
objectId ( mixed $value = null ) : ObjectID | mixed Filters any field in the $fields that has it's value specified as a 'objectId'. It will wraps the $value, if any, into a ObjectID object.
sequence ( integer $value = null ) : integer Prepares the field to have a sequence. If $value is zero or not defined a new auto-increment number will be "generated" for the collection of the schema. The sequence generation is done by the SequenceService.
updatedAtTimestamp ( ) : UTCDateTime Prepares the field to be now.

Method Details

createdAtTimestamp() public method

Prepares the field to be the datetime that the document has been created.
public createdAtTimestamp ( mixed | null $value ) : UTCDateTime
$value mixed | null Value that will be evaluated.
return Mongolid\Serializer\Type\UTCDateTime

objectId() public method

Filters any field in the $fields that has it's value specified as a 'objectId'. It will wraps the $value, if any, into a ObjectID object.
public objectId ( mixed $value = null ) : ObjectID | mixed
$value mixed Value that may be converted to ObjectID.
return Mongolid\Serializer\Type\ObjectID | mixed

sequence() public method

Prepares the field to have a sequence. If $value is zero or not defined a new auto-increment number will be "generated" for the collection of the schema. The sequence generation is done by the SequenceService.
public sequence ( integer $value = null ) : integer
$value integer Value that will be evaluated.
return integer

updatedAtTimestamp() public method

Prepares the field to be now.
public updatedAtTimestamp ( ) : UTCDateTime
return Mongolid\Serializer\Type\UTCDateTime

Property Details

$collection public property

Name of the collection where this kind of document is going to be saved or retrieved from.
public string $collection
return string

$dynamic public property

The $dynamic property tells if the schema will accept additional fields that are not specified in the $fields property. This is useful if you does not have a strict document format or if you want to take full advantage of the "schemaless" nature of MongoDB.
public bool $dynamic
return boolean

$entityClass public property

Name of the class that will be used to represent a document of this Schema when retrieve from the database.
public string $entityClass
return string

$fields public property

The last option is to define a field as another schema by using the syntax 'schema.' This represents an embedded document (or sub-document).
public string[] $fields
return string[]