Options
All
  • Public
  • Public/Protected
  • All
Menu

Abstract Flattable DAO class

Type parameters

Hierarchy

  • MFDao<M>
    • MFFlattableDao

Implements

Index

Constructors

constructor

Properties

Protected db

db: Firestore

The databse to use to store data

mustachePath

mustachePath: string = Reflect.getMetadata('mustachePath', this.constructor)

Collection path with mustache document ids (e.g. lists/{lists}/items)

Protected Optional storage

storage: Bucket

The bucket where files will be stored

Private subDAOs

subDAOs: IMFSubDAOs

List of sub daos used

Methods

beforeSave

  • beforeSave(model: Partial<M>, idOrLocation?: string | Partial<IMFLocation>): Promise<Partial<M>>
  • Override this method to execute actions before saving document in database

    Parameters

    • model: Partial<M>

      the document to save

    • Optional idOrLocation: string | Partial<IMFLocation>

      id or location (pathIds) where the document will be saved

    Returns Promise<Partial<M>>

    Promise with the document that will be saved instead of the input one

create

Private create_subDocs

  • Create subdocuments (even empty ones)

    Parameters

    • data: Partial<M>

      Subdocument data

    • parentLocation: IMFLocation

      Location of parent document

    • Default value options: IMFSaveOptions = {}

      Create options

    Returns Promise<object[]>

delete

deleteByReference

  • deleteByReference(reference: DocumentReference): Promise<void>

deleteFile

  • deleteFile(fileObject: IMFFile): Promise<void>
  • Override this method to delete files from somewhere else than in firestore storage

    Parameters

    • fileObject: IMFFile

      File object containing the file to delete

    Returns Promise<void>

extractMyData

  • extractMyData(data: Partial<M>): Partial<M>
  • extract from main model data intended to sub model

    Parameters

    • data: Partial<M>

      main model data

    Returns Partial<M>

get

  • Get a model from database from id or location

    Parameters

    • idOrLocation: string | IMFLocation

      id or location of the document in database

    • Optional options: IMFGetOneOptions

      (withSnapshot, completeOnFirst, cacheable)

    Returns Promise<M>

    asynchronous answer with model

getByPath

  • Get a model from database from its path

    Parameters

    • path: string

      String path to the document in database

    • Optional options: IMFGetOneOptions

      (withSnapshot, completeOnFirst, cacheable)

    Returns Promise<M>

    asynchronous answer with model

getByReference

  • getByReference(reference: DocumentReference, options?: IMFGetOneOptions): Promise<M>

getList

getModelFromSnapshot

  • getModelFromSnapshot(snapshot: DocumentSnapshot): M

Private getModelWithSubDocsFromMainModel

  • getModelWithSubDocsFromMainModel(mainModel: M, options?: IMFGetOneOptions): Promise<M>
  • Rebuild a model with data from subdocuments

    Parameters

    • mainModel: M

      The main model

    • Default value options: IMFGetOneOptions = {}

      Options to apply to fetch subdocs

    Returns Promise<M>

Abstract getNewModel

  • getNewModel(data?: Partial<M>, location?: Partial<IMFLocation>): M

getReference

  • getReference(idOrLocation: string | Partial<IMFLocation>): DocumentReference | CollectionReference

getReferenceFromPath

  • getReferenceFromPath(path: string): DocumentReference | CollectionReference
  • Get a reference from a compatible path

    Parameters

    • path: string

      The path for which get a reference

    Returns DocumentReference | CollectionReference

    a CollectionReference or a documentReference depending on the path param

getSnapshot

Private get_subDocs

Private initAllSubDao

  • initAllSubDao(): void

Private instantiateSubDao

  • instantiateSubDao(subDaoPath: string): SubMFDao

isCompatible

  • isCompatible(modelOrReference: M | DocumentReference | CollectionReference): boolean
  • Check if the model or reference is compatible with this DAO based on its path

    Parameters

    • modelOrReference: M | DocumentReference | CollectionReference

      Model or reference to chheck

    Returns boolean

saveFile

  • Override this method to save files somewhere else than in firestore storage

    Parameters

    • fileObject: IMFFile

      File object containing the file to save

    • location: string | IMFLocation

      id or location (pathIds) of the document containing the file object

    Returns Promise<IMFFile>

    Promise of the file object containing storage informations

update

Private update_subDocs

  • Update subdocuments the same way normal update does

    Parameters

    • data: Partial<M>

      Subdocument data

    • Optional parentLocation: IMFLocation

      Location of the parent document

    • Default value options: IMFUpdateOptions<M> = {}

      Update options

    Returns Promise<Partial<M>[]>

Generated using TypeDoc