@jiway/firestorm-core - v1.1.1
    Preparing search index...

    Class Repository<T_model>Abstract

    A repository is a typed access to a specific collection

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    firestorm: Firestorm

    Instance of firestORM this repository uses to reach the DB

    path: Path

    Path of the repository

    Accessors

    • get collectionPath(): string

      Gets the path to the collection of this repository

      Returns string

    • get collectionRef(): CollectionReference<DocumentData, DocumentData>

      Gets a collection reference to the collection of this repository

      Returns CollectionReference<DocumentData, DocumentData>

      Collection ref to this repository

    • get documentBlueprint(): Record<string, PropertyBluePrint>

      Gets the blueprint for a document built with the type of this repository

      Returns Record<string, PropertyBluePrint>

      ⚠️ Not ready

    • get firestore(): Firestore

      Instance of firestore this repository uses to reach the DB

      Returns Firestore

    • get isOnSubcollection(): boolean

      Whether or not this repository is a subcollection or not

      Returns boolean

    • get type(): Type<T_model>

      Gets the type this repository work on

      Returns Type<T_model>

    • get typeName(): string

      Gets the name of the type.

      Returns string

      Don't rely on its result to do stuff, the name will get mangled after compilation.

    Methods

    • Converts multiple documents to their corresponding model

      Parameters

      Returns T_model[]

      The converted models

    • Converts a document to a model (if the id is not in the document, it is lost in the process)

      Parameters

      Returns T_model

      The converted model

    • Converts a snapshot to a model

      Parameters

      • documentSnapshot: DocumentSnapshot

        Document snapshot in firestore

      Returns T_model

      Converts a document snapshot to a model

    • Gets a reference to the document corresponding to this id.

      Parameters

      • id: string

        Id for which you want a document ref

      Returns DocumentReference

      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

      Parameters

      Returns DocumentReference

      A document ref corresponding to the model

    • Gets a reference to the document corresponding to this model.

      Parameters

      • modelOrId: string | IFirestormModel

        Id or model for which you want a document ref

      Returns DocumentReference

      A document ref corresponding to the model

    • Gets a document reference for each of the models provided.

      Parameters

      • ids: string[]

        Ids for which you want document refs

      Returns DocumentReference<DocumentData, DocumentData>[]

      A document ref for each of the models provided in the same order

      getDocumentRef For the rules on each individual model/documentRef

    • Gets a document reference for each of the models provided.

      Parameters

      Returns DocumentReference<DocumentData, DocumentData>[]

      A document ref for each of the models provided in the same order

      getDocumentRef For the rules on each individual model/documentRef

    • Gets a document reference for each of the models provided.

      Parameters

      • modelsOrIds: (string | IFirestormModel)[]

        Ids or models for which you want document refs

      Returns DocumentReference<DocumentData, DocumentData>[]

      A document ref for each of the models provided in the same order

    • Converts multiple models to their corresponding document

      Parameters

      • models: Partial<T_model>[]

        Models to convert

      Returns FirestoreDocument[]

      The converted documents

    • Converts a partial model to a document

      Parameters

      • model: Partial<T_model>

        Model to convert

      Returns FirestoreDocument

      The converted document

    • Builds the path to a document

      Parameters

      • modelOrId: string | IFirestormModel

        Model or id for which you want the Firestore's DB path

      Returns string

    • Build a path to a new ressource using the information of the repository and a way to locate the other resource

      Parameters

      • location: PathLike

        Location of the other resource relative to this.

      Returns Path

    • Runs a tansaction on the transaction function provided

      Parameters

      • transactionFnc: TransactionFnc

        Operations to do durring the transaction

      • Optionaloptions: TransactionOptions

        Transaction options

      Returns Promise<void>

    • Converts a firestORM query to a firestore query

      Parameters

      Returns Query

      The firestorm query