Class: Collection

Collection(configurationopt) → {Collection}

The Collection type maintains an ordered list of State items.

Constructor

new Collection(configurationopt) → {Collection}

Create a list of Entity-like objects for later retrieval.
Parameters:
Name Type Attributes Default Description
configuration Object <optional>
{} Configuration object.
Properties:
Name Type Description
@entity Object Fabric-bound entity object.
Source:
Returns:
Configured instance of the the Collection.
Type
Collection

Methods

(async) _patchTarget(path, patches)

Modify a target document using an array of atomic updates.
Parameters:
Name Type Description
path String Path to the document to modify.
patches Array List of operations to apply.
Source:

_setKey(name)

Sets the `key` property of collection settings.
Parameters:
Name Type Description
name String Value to set the `key` setting to.
Source:

asMerkleTree() → {MerkleTree}

Current elements of the collection as a MerkleTree.
Source:
Returns:
Type
MerkleTree

(async) create(entity) → {Promise}

Create an instance of an Entity.
Parameters:
Name Type Description
entity Object Object with properties.
Source:
Returns:
Resolves with instantiated Entity.
Type
Promise

findByField(name, value)

Find a document by specific field.
Parameters:
Name Type Description
name String Name of field to search.
value String Value to match.
Source:

findByName(name)

Find a document by the "name" field.
Parameters:
Name Type Description
name String Name to search for.
Source:

findBySymbol(symbol)

Find a document by the "symbol" field.
Parameters:
Name Type Description
symbol String Value to search for.
Source:

get(path) → {Mixed}

Retrieve a key from the State.
Parameters:
Name Type Description
path Path Key to retrieve.
Source:
Returns:
Type
Mixed

getByID(id)

Retrieve an element from the collection by ID.
Parameters:
Name Type Description
id String Document identifier.
Source:

getLatest()

Retrieve the most recent element in the collection.
Source:

(async) import(state, commit)

Loads State into memory.
Parameters:
Name Type Description
state State State to import.
commit Boolean Whether or not to commit the result.
Source:
Fires:
  • event:message Will emit one Snapshot message.

list() → {Array}

Generate a list of elements in the collection.
Deprecated:
  • Yes
Source:
Returns:
Type
Array

map() → {Array}

Generate a hashtable of elements in the collection.
Source:
Returns:
Type
Array

(async) push(data) → {Number}

Adds an Entity to the Collection.
Parameters:
Name Type Description
data Mixed Entity to add.
Source:
Returns:
Length of the collection.
Type
Number

set(path) → {Mixed}

Set a key in the State to a particular value.
Parameters:
Name Type Description
path Path Key to retrieve.
Source:
Returns:
Type
Mixed

toTypedArray()

Provides the Collection as an Array of typed elements. The type of these elments are defined by the collection's type, supplied in the constructor.
Source: