Entity class for ClayDB
Installation
$ npm install clay-entity --save
Usage
'use strict' const clayEntity = let entity01 = console
API
clay-entity@2.1.10
Entity class for ClayDB
- Functions
DecoratedEntity
Class
Functions
Entity
create(args) -> Create a Entity instance
Param | Type | Description |
---|---|---|
args | * |
DecoratedEntity
decorate(decorate) -> Decorate an entity
Param | Type | Description |
---|---|---|
decorate | Entity |
boolean
isEntity(obj) -> Detect a instance is entity or not
Param | Type | Description |
---|---|---|
obj | * | Object to check |
DecoratedEntity
Class
new DecoratedEntity(entity)
Constructor of DecoratedEntity class
Param | Type | Description |
---|---|---|
entity | Entity | Entity to decorate |
*
entity.get(name) -> Get entity attribute.
Param | Type | Description |
---|---|---|
name | string | Name of attribute |
DecoratedEntity
entity.set(name, value) -> Set value
Param | Type | Description |
---|---|---|
name | string | Name of attribute to set |
value | * | Value to set |
DecoratedEntity
entity.set(attributes, options) -> Set values
Param | Type | Description |
---|---|---|
attributes | Object | Attributes to set |
options | Object | Optional settings |
options.allowReserved | boolean | Allow to set reserved |
DecoratedEntity
entity.at(at) -> Set $$at attribute
Param | Type | Description |
---|---|---|
at | Date | Date data set at |
Date
entity.at() -> Get $$at attribute
DecoratedEntity
entity.by(by) -> Set $$by attribute
Param | Type | Description |
---|---|---|
by | string | Lump id |
string
entity.by() -> Get $$by attribute
DecoratedEntity
entity.seal(privateKey) -> Seal this entity
Param | Type | Description |
---|---|---|
privateKey | string | Private key to seal |
string
entity.seal() -> Get seal
DecoratedEntity
entity.as(as) -> Set resource name as as
Param | Type | Description |
---|---|---|
as | string | As |
string
entity.as() -> Get as
DecoratedEntity
entity.num(num) -> Set entity number as num
Param | Type | Description |
---|---|---|
num | string | As |
string
entity.num() -> Get num
boolean
entity.verify(publicKey) -> Verify the entity with public key
Param | Type | Description |
---|---|---|
publicKey | string |
Object
entity.toValues() -> Convert into value object
License
This software is released under the Apache-2.0 License.