Class Metadata

The Metadata instance tracks the state of an object and checks if the object state was changed since last load/update. The metadata keeps therefore the state of:

  • in which state the object currently is
  • which db managed the instance
  • the metadata of the object (id, version, bucket)
  • which is the owning object (root object) of an embedded object

Metadata#get(object) can be used on any managed object to retrieve the metadata of the root object

Hierarchy

Implements

Constructors

Properties

acl: Acl
decodedKey: null | string = null
enabled: boolean
entityManager: null | EntityManager = null
id: null | string = null
type: EntityType<any>
version: null | number

Accessors

  • get bucket(): string
  • Returns string

  • get isAttached(): boolean
  • Indicates if this object already belongs to an db true if this object belongs already to an db otherwise false

    Returns boolean

  • get isAvailable(): boolean
  • Indicates if this object is represents a db object, but was not loaded up to now

    Returns boolean

  • get isDirty(): boolean
  • Indicates that this object was modified and the object was not written back to the db

    Returns boolean

  • get isPersistent(): boolean
  • Indicates if this object represents the state of the db and was not modified in any manner

    Returns boolean

  • get isReady(): boolean
  • Indicates if there is currently no exclusive operation executed true If no exclusive lock is hold

    Returns boolean

  • get key(): null | string
  • Returns null | string

Methods

  • Enable/Disable state change tracking of this object

    Returns

    Parameters

    • newStateTrackingState: boolean

      The new change tracking state

    Returns void

  • Waits on the previously requested operation and calls the doneCallback if the operation is fulfilled

    Returns

    A promise which completes successfully, when the previously requested operation completes

    Parameters

    • Optional doneCallback: ((this: Metadata) => any)

      The callback which will be invoked when the previously operations on this object is completed.

    • Optional failCallback: ((error: Error) => any)

      When the lock can't be released caused by a none recoverable error

        • (error: Error): any
        • Parameters

          • error: Error

          Returns any

    Returns Promise<Metadata>

  • Indicates the the object is modified by the user

    Returns

    Returns void

  • Indicates that the associated object is not stale

    An object is stale if it correlates the database state and is not modified by the user.

    Returns

    Returns void

  • Indicates the the object is removed

    Returns

    Returns void

  • Indicates that the associated object isn't available

    Returns

    Returns void

  • Throws the corresponding error if a property is accessed before the owning object is loaded

    Throws

    an exception if the object properties aren't available and the object is enabled

    Parameters

    • property: string

    Returns void

  • Protected

    Try to aquire an exclusive lock and executes the given callback.

    Returns

    A promise

    Throws

    If the lock can't be aquired

    Type Parameters

    • T

    Parameters

    • callback: (() => Promise<T>)

      The exclusive operation to execute

        • (): Promise<T>
        • Returns Promise<T>

    • Optional critical: boolean = false

      Indicates if the operation is critical. If the operation is critical and the operation fails, then the lock will not be released

    Returns Promise<T>

  • Returns the metadata of the managed object

    Returns

    Parameters

    Returns Metadata

Generated using TypeDoc