Readonly
$attributesReadonly
$dirtyReadonly
$istrue
if the entry has been removed from the database.
Readonly
$istrue
if the entry has unsaved modifications.
Readonly
$istrue
if the entry has been created locally. Similar to $isNew
, but
stays true
after the entry is persisted to the database.
Readonly
$isOpposite of $isPersisted
.
Readonly
$istrue
if the entry has been persisted to the database.
Readonly
$isReadonly
$originalReadonly
$trxReturn the client session of the transaction
Readonly
_idReadonly
createdReadonly
idReadonly
updatedDelete the entry from the database.
Optional
options: ModelDocumentOptions<DeleteOptions>Remove all field in instance and replace it by provided values.
Values to fill in.
Merge given values into the model instance.
Values to merge with.
Save the entry to the database.
Optional
options: ModelDocumentOptions<InsertOneOptions>Assign client to model options for transactions use. Will throw an error if model instance already linked to a session
It allows to use model init outside a transaction, but save it within a transaction.
const label = await Label.findOrFail(1);
// edit some label props
Database.transaction((client) => {
const documents = await Document.query({ labels: label._id }, { client }).all()
// remove label from documents when new label definition is incompatible
// call .save() for each changed documents (aware of transaction because is from query with client option)
label.useTransaction(client);
label.save();
})
Returns an object with the field values that have been changed.