Options
All
  • Public
  • Public/Protected
  • All
Menu

Abstract Dao class use for subdocuments of flattable model

Hierarchy

Implements

Index

Constructors

constructor

  • new SubMFDao(mustachePath: string, db: Firestore, referentGetNewModel: function, beforeSave: function, storage?: Bucket): SubMFDao
  • Must be called with super

    Parameters

    • mustachePath: string

      subCollection mustache path

    • db: Firestore

      Firestore database to use

    • referentGetNewModel: function

      Parent getNewModelMethod

        • (data?: Partial<any>, location?: Partial<IMFLocation>): any
        • Parameters

          • Optional data: Partial<any>
          • Optional location: Partial<IMFLocation>

          Returns any

    • beforeSave: function

      Parent before save method to apply

        • (model: Partial<any>, location?: string | Partial<IMFLocation>): Promise<Partial<any>>
        • Parameters

          • model: Partial<any>
          • Optional location: string | Partial<IMFLocation>

          Returns Promise<Partial<any>>

    • Optional storage: Bucket

      Bucket if model contains files to save

    Returns SubMFDao

Properties

beforeSave

beforeSave: function

Parent before save method to apply

Type declaration

    • (model: Partial<any>, location?: string | Partial<IMFLocation>): Promise<Partial<any>>
    • Parameters

      • model: Partial<any>
      • Optional location: string | Partial<IMFLocation>

      Returns Promise<Partial<any>>

Protected db

db: Firestore

The databse to use to store data

mustachePath

mustachePath: string

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

Private referentGetNewModel

referentGetNewModel: function

Parent getNewModelMethod

Type declaration

    • (data?: Partial<any>, location?: Partial<IMFLocation>): any
    • Parameters

      • Optional data: Partial<any>
      • Optional location: Partial<IMFLocation>

      Returns any

Protected Optional storage

storage: Bucket

The bucket where files will be stored

Methods

containsSomeValuesForMe

  • containsSomeValuesForMe(data: Object): boolean
  • Returns true or false denpending on if the data contains values applicable to this subDao's submodel

    Parameters

    • data: Object

      The data to check

    Returns boolean

    boolean

create

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>

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<any>

    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<any>

    asynchronous answer with model

getByReference

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

getList

getModelFromSnapshot

  • getModelFromSnapshot(snapshot: DocumentSnapshot): any

getNewModel

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

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

isCompatible

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

    Parameters

    • modelOrReference: any | 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

splitDataByDocId

  • splitDataByDocId(data: Partial<any>): object
  • Splits the data passed as parameter into data applicable to different documents using the same DAO

    Parameters

    • data: Partial<any>

      the data to split

    Returns object

    An object containing the data splitted by docIds

    • [docId: string]: object

update

Generated using TypeDoc