Doc
The Doc
class represents a document in the database. It provides methods to read and write the document.
Docs get returned from reading operations or created by a collection:
ref
The property contains the references to the document:
→ Read more about the Ref
class
data
The property contains the document data:
get
The method allows to get the document:
→ Read more about the get
method
set
The method allows to set the document:
→ Read more about the set
method
update
The method allows to update the document:
→ Read more about the update
method
upset
The method allows to update the document if it exists or set it if it doesn’t:
→ Read more about the upset
method
remove
The method allows to remove the document:
→ Read more about the remove
method
narrow
The method narrows the variable model doc type:
It checks the data structure on the runtime and asserts the type.
→ Read more about variable models
→ Read more about the narrow
method
as
⚠️ Available starting with v10.3.0
The method resolves Typesaurus.SharedDoc
if the model extends the given type. Otherwise, it resolves unknown
preventing the usage of incompatible models:
It allows sharing functionality across the db entities in a type-safe way.