clay-entity
v2.1.11
Published
Entity class for ClayDB
Downloads
225
Readme
Entity class for ClayDB
Installation
$ npm install clay-entity --save
Usage
'use strict'
const clayEntity = require('clay-entity')
{
let entity01 = clayEntity({
title: 'Wonderful Banana'
})
console.log(entity01)
}
API
[email protected]
Entity class for ClayDB
- Functions
DecoratedEntity
Class
Functions
create(args) -> Entity
Create a Entity instance
| Param | Type | Description | | ----- | --- | -------- | | args | * | |
decorate(decorate) -> DecoratedEntity
Decorate an entity
| Param | Type | Description | | ----- | --- | -------- | | decorate | Entity | |
isEntity(obj) -> boolean
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 |
entity.set(name, value) -> DecoratedEntity
Set value
| Param | Type | Description | | ----- | --- | -------- | | name | string | Name of attribute to set | | value | * | Value to set |
entity.set(attributes, options) -> DecoratedEntity
Set values
| Param | Type | Description | | ----- | --- | -------- | | attributes | Object | Attributes to set | | options | Object | Optional settings | | options.allowReserved | boolean | Allow to set reserved |
entity.at(at) -> DecoratedEntity
Set $$at attribute
| Param | Type | Description | | ----- | --- | -------- | | at | Date | Date data set at |
entity.at() -> Date
Get $$at attribute
entity.by(by) -> DecoratedEntity
Set $$by attribute
| Param | Type | Description | | ----- | --- | -------- | | by | string | Lump id |
entity.by() -> string
Get $$by attribute
entity.seal(privateKey) -> DecoratedEntity
Seal this entity
| Param | Type | Description | | ----- | --- | -------- | | privateKey | string | Private key to seal |
entity.seal() -> string
Get seal
entity.as(as) -> DecoratedEntity
Set resource name as as
| Param | Type | Description | | ----- | --- | -------- | | as | string | As |
entity.as() -> string
Get as
entity.num(num) -> DecoratedEntity
Set entity number as num
| Param | Type | Description | | ----- | --- | -------- | | num | string | As |
entity.num() -> string
Get num
entity.verify(publicKey) -> boolean
Verify the entity with public key
| Param | Type | Description | | ----- | --- | -------- | | publicKey | string | |
entity.toValues() -> Object
Convert into value object
License
This software is released under the Apache-2.0 License.