Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MergeStrategy

MergeStrategy is an 'Enum' that determines how entities are merged into an EntityManager.

static

Hierarchy

Index

Constructors

constructor

Properties

_$typeName

_$typeName: string

Type of the enum; set in prototype of each enum

name

name: string

The name of this symbol

Static Disallowed

Disallowed: MergeStrategy = new MergeStrategy()

Disallowed is used to throw an exception if there is an incoming entity with the same key as an entity already in the cache. Use this strategy when you want to be sure that the incoming entity is not already in cache. This is the default strategy for EntityManager.attachEntity.

Static OverwriteChanges

OverwriteChanges: MergeStrategy = new MergeStrategy()

MergeStrategy.OverwriteChanges always updates the cached entity with incoming values even if the entity is in a changed state (added, modified, deleted). After the merge, the pending changes are lost. The new EntityState will be [[EntityState/Unchanged]] unless you’re importing entities in which case the new EntityState will be that of the imported entities.

Static PreserveChanges

PreserveChanges: MergeStrategy = new MergeStrategy()

MergeStrategy.PreserveChanges updates the cached entity with the incoming values unless the cached entity is in a changed state (added, modified, deleted) in which case the incoming values are ignored. The updated cached entity’s EntityState will remain EntityState.Unchanged unless you’re importing entities in which case the new EntityState will be that of the imported entities.

Static SkipMerge

SkipMerge: MergeStrategy = new MergeStrategy()

SkipMerge is used to ignore incoming values. Adds the incoming entity to the cache only if there is no cached entity with the same key. This is the fastest merge strategy but your existing cached data will remain “stale”.

Methods

toJSON

  • toJSON(): { _$typeName: any; name: string }
  • Return enum name and symbol name

    Returns { _$typeName: any; name: string }

    • _$typeName: any
    • name: string

toString

  • toString(): string

Static contains

  • Returns whether an Enum contains a specified symbol.

    let symbol = DayOfWeek.Friday;
    if (DayOfWeek.contains(symbol)) {
        // do something
    }
    

    Parameters

    Returns boolean

    Whether this Enum contains the specified symbol.

Static fromName

  • fromName(name: string): any
  • Returns an Enum symbol given its name.

    let dayOfWeek = DayOfWeek.from("Thursday");
    // nowdayOfWeek === DayOfWeek.Thursday
    

    Parameters

    • name: string

      Name for which an enum symbol should be returned.

    Returns any

    The symbol that matches the name or 'undefined' if not found.

Static getNames

  • getNames(): string[]
  • Returns the names of all of the symbols contained within this Enum.

    let symbols = DayOfWeek.getNames();
    

    Returns string[]

    All of the names of the symbols contained within this Enum.

Static getSymbols

  • Returns all of the symbols contained within this Enum.

    let symbols = DayOfWeek.getSymbols();
    

    Returns BreezeEnum[]

    All of the symbols contained within this Enum.

Static resolveSymbols

  • resolveSymbols(): { name: string; symbol: BreezeEnum }[]
  • Seals this enum so that no more symbols may be added to it. This should only be called after all symbols have already been added to the Enum. This method also sets the 'name' property on each of the symbols.

    DayOfWeek.resolveSymbols();
    

    Returns { name: string; symbol: BreezeEnum }[]

Generated using TypeDoc