Ref
The Ref
class represents a reference to a document in the database. It provides methods to read and write the document.
Refs get returned from writing operations, it can be accessed through doc or created by a collection:
id
The property contains the document id:
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
as
⚠️ Available starting with v10.3.0
The method resolves Typesaurus.SharedRef
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.