Creates a new CollectionCrudRepository on a model
Protected ReadonlyfirestormInstance of firestORM this repository uses to reach the DB
ProtectedpathPath of the repository
Gets the path to the collection of this repository
ProtectedcollectionGets a collection reference to the collection of this repository
Collection ref to this repository
Gets the blueprint for a document built with the type of this repository
ProtectedfirestoreInstance of firestore this repository uses to reach the DB
Whether or not this repository is a subcollection or not
ProtectedstorageThe storage of metadatas of this repository
ProtectedtypeThe metadatas corresponding to the type of this repository
ProtectedtypeRuns an aggregation query on the collection.
The aggregations to perform
Optionalquery: IQueryBuildBlock | QueryA narrowing query to aggregate only on a portion of the collection.
The aggregation result
Creates a new item in the database.
Not providing an id in the item auto generates an id.
If an item with the same id is already present it will override it destructively (the entire document will be replaced in database)
Model to create
A promise that resolved when and on the item that has been created.
ProtectedcreateCreates an includer that can be resolved later
Models to resolve
The resolver created
Creates a collection of items in the database. The operation is batched, so either they are all created or none are created.
It behaves exactly like createAsync on a per model basis.
Models to create
A promise that resolves when the items have been created.
Delete all the documents in a query.
This is operation is partially batched, it deletes all the documents present when starting the query but doesn't delete the documents created while the query is running.
⚠️ It's meant to be used in backend. Avoid doing this in front-end clients.
Deletes a document in the database. It doesn't delete its subcollection if any.
Trying to delete a document that doesn't exist will just silently fail
Id of the document to delete
A promise that returns when the document has been deleted
Deletes a document in the database. It doesn't delete its subcollection if any.
Trying to delete a document that doesn't exist will just silently fail
This doesn't typecheck the model. It only types check that you provided an id
Model of the document to delete.
A promise that returns when the document has been deleted
Deletes multiple documents It doesn't delete its subcollection if any.
This operation is batched
Trying to delete a document that doesn't exist silently fails.
Ids of the document to delete
Deletes multiple documents It doesn't delete its subcollection if any.
This operation is batched
Trying to delete a document that doesn't exist silently fails.
This doesn't typecheck the model. It only checks that you provided an id
Models with the id of the documents to delete
Converts multiple documents to their corresponding model
Documents to convert
The converted models
Converts a document to a model (if the id is not in the document, it is lost in the process)
Document to convert
The converted model
Check if a document with this id already exists in the database
Id of the item to check the existency
A promise returning true if an item with this id exists in the collection
ProtectedfirestoreConverts a snapshot to a model
Document snapshot in firestore
Converts a document snapshot to a model
ProtectedgetGets a reference to the document corresponding to this id.
Id for which you want a document ref
A document ref corresponding to the model
Gets a reference to the document corresponding to this model.
If the model doesn't have any id, it will give you a reference to a new document, generate an id and assign it to the model
Model for which you want a document ref
A document ref corresponding to the model
Gets a reference to the document corresponding to this model.
Id or model for which you want a document ref
A document ref corresponding to the model
ProtectedgetGets a document reference for each of the models provided.
Ids for which you want document refs
A document ref for each of the models provided in the same order
Gets a document reference for each of the models provided.
Models for which you want document refs
A document ref for each of the models provided in the same order
Gets a document reference for each of the models provided.
Ids or models for which you want document refs
A document ref for each of the models provided in the same order
Picks the randomness selection method.
A random element of the collection or null if no elements.
A random element of the collection or null if no elements.
Creates a repository using a generator function
Type of the repository
Type of the model of the new repo
Generator function of the repository
Type of the model
The path to the collection or document to get a repository on
Listens to the changes of the full collection.
An observable on the changes of any document in the collection
Listens to the changes of a document
Id of the document to listen to
An observable on the document's changes
Listens to the changes of a document
Model with the id of the document to listen to
An observable on the document's changes
Listens to the changes of documents in a query
Query on the documents
An observable on the documents matched by the query changes
Converts multiple models to their corresponding document
Models to convert
The converted documents
Converts a partial model to a document
Model to convert
The converted document
Builds the path to a document
Model or id for which you want the Firestore's DB path
Queries a collection of items
Query
Optionalincludes: Partial<Record<keyof T_model, boolean>>Optional params for querying linked documents.
A promise on the items that are results of the query
ProtectedresolveCreates an includer that is resolved immediately. It can still be reused.
Includes for the model
Models to resolve
ProtectedresolveProtectedrunRuns a tansaction on the transaction function provided
Operations to do durring the transaction
Optionaloptions: TransactionOptionsTransaction options
ProtectedtoConverts a firestORM query to a firestore query
Query to convert
The firestorm query
Modifies an item in the database.
Partial or full model to update. It must have an id.
A promise resolved when the item has been updated.
Repository with a basic CRUD implementation.