public
boolean
|
#
replace( boolean $runValidation = true )
Replaces the current document.
Replaces the current document.
NOTE: This will overwrite entire document.
Any filtered out properties will be removed as well.
The record is inserted as a documnent into the database collection, if exists it will be replaced.
Validation will be performed before saving the record. If the validation fails,
the record will not be saved. You can call getErrors() to retrieve the
validation errors.
Parameters
- $runValidation
whether to perform validation before saving the record.
If the validation fails, the record will not be saved to database.
Returns
boolean whether the saving succeeds
Since
v1.0
|
public
boolean
|
#
save( boolean $runValidation = true )
Saves the current document.
Saves the current document.
The document is inserted into collection if it is not already saved. The
check whether to update or insert document is dony by primary key.
Validation will be performed before saving the record. If the validation fails,
the record will not be saved. You can call getErrors() to retrieve the
validation errors.
If the record is saved its scenario will be set to be 'update'.
And if its primary key is of type of MongoId , it will be set after save.
Parameters
- $runValidation
whether to perform validation before saving the record.
If the validation fails, the record will not be saved to database.
Returns
boolean whether the saving succeeds
Since
v1.0
Ignored
|
public
boolean
|
#
upsert( boolean $runValidation = true )
Updates or inserts the current document. This will try to update existing fields.
Will keep already stored data if present in document.
Updates or inserts the current document. This will try to update existing fields.
Will keep already stored data if present in document.
If document does not exist, a new one will be inserted.
Parameters
Returns
boolean
Throws
|
public
boolean
|
#
insert( Maslosoft\Addendum\Interfaces\AnnotatedInterface $model = null )
Inserts a document into the collection based on this active document attributes.
Inserts a document into the collection based on this active document attributes.
Note, validation is not performed in this method. You may call validate() to perform the validation.
After the record is inserted to DB successfully, its scenario will be set to be 'update'.
Parameters
- $model
- if want to insert different model than set in constructor
Returns
boolean whether the attributes are valid and the record is inserted successfully.
Throws
Since
v1.0
Ignored
|
public
boolean
|
#
update( array $attributes = null )
Updates the document represented by this active document.
All loaded attributes will be saved to the database.
Note, validation is not performed in this method. You may call validate() to perform the validation.
Updates the document represented by this active document.
All loaded attributes will be saved to the database.
Note, validation is not performed in this method. You may call validate() to perform the validation.
Parameters
- $attributes
list of attributes that need to be updated. Defaults to null,
meaning all attributes that are loaded from DB will be saved.
Returns
boolean whether the update is successful
Throws
Since
v1.0
Ignored
|
public
|
#
updateOne( array|Maslosoft\Mangan\Interfaces\CriteriaInterface $criteria = null, array $attributes = null, boolean $modify = false )
Updates one document with the specified criteria and attributes
Updates one document with the specified criteria and attributes
This is more raw update:
- Does not raise any events or signals
- Does not perform any validation
Parameters
- $criteria
- query criteria.
- $attributes
list of attributes that need to be saved. Defaults to null,
meaning all attributes that are loaded from DB will be saved.
- $modify
- tu force update/upsert document
Since
v1.0
|
public
boolean|mixed[]
|
|
public
boolean
|
#
delete( )
Deletes the databse document corresponding to this Document .
Deletes the databse document corresponding to this Document .
Returns
boolean whether the deletion is successful.
Throws
Since
v1.0
Ignored
|
public
|
#
deleteByPk( mixed $pkValue, array|Maslosoft\Mangan\Interfaces\CriteriaInterface $criteria = null )
Deletes document with the specified primary key.
Deletes document with the specified primary key.
Additional $criteria can be used to filter out which document should be deleted.
See find() for detailed explanation about $criteria .
Parameters
- $pkValue
- primary key value(s). Use array for multiple primary keys. For composite key, each key value must be an array (column name=>column value).
- $criteria
- query criteria.
Since
v1.0
Ignored
|
public
|
#
deleteAllByPk( mixed[] $pkValues, array|Maslosoft\Mangan\Interfaces\CriteriaInterface $criteria = null )
Deletes documents with the specified primary keys.
Deletes documents with the specified primary keys.
Additional $criteria can be used to filter out which documents should be deleted.
See find() for detailed explanation about $criteria .
Parameters
- $pkValues
- Primary keys array
- $criteria
- query criteria.
Since
v1.0
Ignored
|
public
|
#
deleteAll( array|Maslosoft\Mangan\Interfaces\CriteriaInterface $criteria = null )
Deletes documents with the specified criteria.
Deletes documents with the specified criteria.
Optional $criteria can be used to filter out which documents should be deleted.
See find() for detailed explanation about $criteria.
Parameters
- $criteria
- query criteria.
Since
v1.0
Ignored
|
public
|
#
deleteOne( array|Maslosoft\Mangan\Interfaces\CriteriaInterface $criteria = null )
Deletes one document with the specified primary keys.
Deletes one document with the specified primary keys.
Optional $criteria can be used to filter out which document should be deleted.
Does not raise beforeDelete event
See find() for detailed explanation about $criteria
Parameters
- $criteria
- query criteria.
Since
v1.0
Ignored
|
public
boolean
|
#
refresh( )
Repopulates this active document with the latest data.
Repopulates this active document with the latest data.
Returns
boolean whether the row still exists in the database. If true, the latest data will be populated to this active record.
Since
v1.0
Ignored
|
public
MongoCollection
|
#
getCollection( )
Get working mongo collection instance.
Get working mongo collection instance.
Should not be called manually in most cases.
Returns
MongoCollection
Ignored
|