Creates a new CrudRepository on a model
Type on which the repository operates
The instance of firestore this repository connects to
Optionalparents: CollectionDocumentTuplesThe optional parent collections for repositories of subcollections
Protected ReadonlyfirestoreInstance of firestore this repository uses to reach the DB
Protected OptionalparentsGets 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
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
ProtectedtypeGets the name of the type.
Runs 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.
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 types check 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
Tries to find an item by its id in the database
Id of the item to find
Optionalincludes: Partial<Record<keyof T_model, boolean>>A promise containing either the item retrieved or null if not found
ProtectedfirestoreGets the basic CRUD repository for a model
Type of the model
Type of the 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
Creates a repository using a generator function
Type of the repository
Type of the model
Generator function of the repository
Type of the model
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>>A promise on the items that are results of the query
ProtectedrunRuns 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.