Class Collection<T, M, C>Abstract

Type Parameters

  • T extends DataType

    A collection data type definition.

  • M = any

    A CollectionMutator received collection type definition.

  • C = any

Hierarchy

Constructors

  • The Collection() class hold data resources. User can choose either fetch from database or cache.

    Type Parameters

    • T extends DataType

      A collection data type definition.

    • M = any

      A CollectionMutator received collection type definition.

    • C = any

    Parameters

    • name: string

      The collection name.

    Returns Collection<T, M, C>

Properties

collectionMutator: CollectionMutator<M>
dbInstance: C
debug: Debugger = ...
name: string
resourcePath: string
rootPath: string = ...

Methods

  • The makeReferableEntities() method converts fetched data to ReferableMapEntity.

    Type Parameters

    Parameters

    • data: G

      Fetched data

    Returns Record<string, G[keyof G]>

  • The fetchNoRef() method fetch the collection from database without referable property, mutate, and then save it as a cache.

    Returns

    Promise

    Parameters

    • Optional mutator: CollectionMutator<M> = ...

      Mutator mutates raw collection data from the database to certain format check Mutator for some built-in mutators.

    Returns Promise<LiveDMap<string, T[keyof T]>>

  • Protected

    The handleChanges() abstract method will be used to handle DataChanges to match the database required form. Note: Different databases require different procedures to process DataChanges.

    Abstract

    Parameters

    • changes: DataChanges[]

      Received changes.

    Returns Promise<DataChanges[]>

  • The pushChanges() method push incoming changes to the database.

    Parameters

    • changes: ChangeList

      Received changes.

    • strict: boolean = true

      Only allow LiveDMap changes to be pushed to the database.

    Returns Promise<boolean>

  • The readFromCacheNoRef() method retrieve data from saved cache without referable property.

    Parameters

    • autoFetch: boolean = false

      Automatically fetch data from the database if it is not presented.

    Returns Promise<null | DMap<string, T[keyof T]>>

  • Protected

    The retrieveCollection() abstract method will be called internally to fetch collection data. Note: Different databases require different procedures to access its collection.

    Abstract

    Returns Promise<M>

  • The setDefaultMutator() method set Collection's defaultMutator, which will be used when resources are being fetched automatically.

    Parameters

    • mutator: CollectionMutator<M>

      Mutator mutates raw collection data from the database to certain format check Mutator for some built-in mutators.

    Returns Collection<T, M, C>

  • Protected

    The verifyChanges() abstract method will be used to verify changes pushed to the database. Note: Different databases may require different procedures.

    Abstract

    Parameters

    • changes: DataChanges[]

      Expected changes.

    Returns Promise<boolean>

Generated using TypeDoc