Options
All
  • Public
  • Public/Protected
  • All
Menu

Entity mixin. When applied to some base class (recommended one is Base), turns it into entity. Entity may have several fields, which are properties decorated with field decorator.

To apply this mixin use the Entity.mix property, which represents the mixin lambda.

Another decorator, calculate, marks the method, that will be used to calculate the value of field.

Example:

class Author extends Entity.mix(Base) {
    @field()
    firstName       : string
    @field()
    lastName        : string
    @field()
    fullName        : string

    @calculate('fullName')
    calculateFullName () : string {
        return this.firstName + ' ' + this.lastName
    }
}

Hierarchy

  • object
    • Entity

Index

Properties

graph

graph: Replica

A reference to the graph, this entity belongs to. Initially empty, and is populated when the entity instance is added to the replica (Replica.addEntity)

Accessors

$

  • get $(): {}
  • An object, which properties corresponds to the ChronoGraph Identifiers, created for every field.

    For example:

    class Author extends Entity.mix(Base) {
        @field()
        firstName       : string
        @field()
        lastName        : string
    }
    
    const author = Author.new()
    
    // identifier for the field `firstName`
    author.$.firstName
    
    const firstName = replica.read(author.$.firstName)

    Returns {}

$$

$entity

Static $entity

Methods

commit

commitAsync

enterGraph

  • enterGraph(replica: Replica): void

leaveGraph

Generated using TypeDoc