2.1.11 • Published 6 years ago

clay-entity v2.1.11

Weekly downloads
397
License
Apache-2.0
Repository
github
Last release
6 years ago

Build Status npm Version JS Standard

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

clay-entity@2.1.10

Entity class for ClayDB

Functions

create(args) -> Entity

Create a Entity instance

ParamTypeDescription
args*

decorate(decorate) -> DecoratedEntity

Decorate an entity

ParamTypeDescription
decorateEntity

isEntity(obj) -> boolean

Detect a instance is entity or not

ParamTypeDescription
obj*Object to check

DecoratedEntity Class

new DecoratedEntity(entity)

Constructor of DecoratedEntity class

ParamTypeDescription
entityEntityEntity to decorate

entity.get(name) -> *

Get entity attribute.

ParamTypeDescription
namestringName of attribute

entity.set(name, value) -> DecoratedEntity

Set value

ParamTypeDescription
namestringName of attribute to set
value*Value to set

entity.set(attributes, options) -> DecoratedEntity

Set values

ParamTypeDescription
attributesObjectAttributes to set
optionsObjectOptional settings
options.allowReservedbooleanAllow to set reserved

entity.at(at) -> DecoratedEntity

Set $$at attribute

ParamTypeDescription
atDateDate data set at

entity.at() -> Date

Get $$at attribute

entity.by(by) -> DecoratedEntity

Set $$by attribute

ParamTypeDescription
bystringLump id

entity.by() -> string

Get $$by attribute

entity.seal(privateKey) -> DecoratedEntity

Seal this entity

ParamTypeDescription
privateKeystringPrivate key to seal

entity.seal() -> string

Get seal

entity.as(as) -> DecoratedEntity

Set resource name as as

ParamTypeDescription
asstringAs

entity.as() -> string

Get as

entity.num(num) -> DecoratedEntity

Set entity number as num

ParamTypeDescription
numstringAs

entity.num() -> string

Get num

entity.verify(publicKey) -> boolean

Verify the entity with public key

ParamTypeDescription
publicKeystring

entity.toValues() -> Object

Convert into value object

License

This software is released under the Apache-2.0 License.

Links