Class FirestormMetadata<T_model>

Metadatas linked to a type that holds information:

  • on how to convert it to and from firestore.
  • the fields remapped
  • the conversions of complex fields
  • the subcollections
  • the fields ignored

Type Parameters

  • T_model

    Type this metadatas are for

Constructors

Properties

collection?: string

Collection's path

type: Type<T_model>

Type this metadatas are for

Accessors

  • get documentBlueprint(): Record<string, PropertyBluePrint>
  • Creates a blueprint of the document created by the model

    Returns Record<string, PropertyBluePrint>

    ⚠️ Not ready

  • get modelProperties(): MapIterator<FirestormPropertyMetadata<any>>
  • List of the properties that are mapped to a document, including ignored keys.

    Returns MapIterator<FirestormPropertyMetadata<any>>

  • get relationshipMetadatas(): FirestormPropertyMetadataWithRelationship[]
  • Returns FirestormPropertyMetadataWithRelationship[]

Methods

  • Adds a converter for a field from the document to the model

    Type Parameters

    • T

    Parameters

    Returns void

  • Marks a key as ignored when deserializing a document

    Parameters

    • propertyName: string

      The name of the property to ignore

    Returns void

  • Adds a converter for a property from the model to the document

    Type Parameters

    • T

    Parameters

    Returns void

  • Marks a key in the model to be read when deserializing a document

    Parameters

    • propertyName: string

      They name of the property in the model

    Returns string

    The default key that will be used in the document

  • Overrides the key in a document mapping to a the key in the model

    Parameters

    • propertyName: string

      Key in the model

    • mapTo: string

      Matching key in the document

    Returns void

  • Marks a field as being a subcollection

    Type Parameters

    • T

    Parameters

    • propertyName: string

      The name of the property of the subcollection

    • type: Type<T>

    Returns void

  • Converts a document to a model

    Parameters

    Returns T_model

    The model created from the document

  • Converts a model or part of a model to a document.

    Parameters

    • model: Partial<T_model>

      Model to convert

    Returns FirestoreDocument

    The document created from the model