Entity class for ClayDB
npm install clay-entity
height="148"
style="height:148px"
/>
[![Build Status][bd_travis_shield_url]][bd_travis_url]
[![npm Version][bd_npm_shield_url]][bd_npm_url]
[![JS Standard][bd_standard_shield_url]][bd_standard_url]
[bd_repo_url]: https://github.com/realglobe-Inc/clay-entity
[bd_travis_url]: http://travis-ci.org/realglobe-Inc/clay-entity
[bd_travis_shield_url]: http://img.shields.io/travis/realglobe-Inc/clay-entity.svg?style=flat
[bd_travis_com_url]: http://travis-ci.com/realglobe-Inc/clay-entity
[bd_travis_com_shield_url]: https://api.travis-ci.com/realglobe-Inc/clay-entity.svg?token=
[bd_license_url]: https://github.com/realglobe-Inc/clay-entity/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/realglobe-Inc/clay-entity
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/realglobe-Inc/clay-entity.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/realglobe-Inc/clay-entity.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/realglobe-Inc/clay-entity
[bd_gemnasium_shield_url]: https://gemnasium.com/realglobe-Inc/clay-entity.svg
[bd_npm_url]: http://www.npmjs.org/package/clay-entity
[bd_npm_shield_url]: http://img.shields.io/npm/v/clay-entity.svg?style=flat
[bd_standard_url]: http://standardjs.com/
[bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
Entity class for ClayDB
Installation
-----
``bash`
$ npm install clay-entity --save
Usage
---------
`javascript
'use strict'
const clayEntity = require('clay-entity')
{
let entity01 = clayEntity({
title: 'Wonderful Banana'
})
console.log(entity01)
}
`
API
---------
Entity class for ClayDB
+ Functions
+ create(args)
+ decorate(decorate)
+ isEntity(obj)
+ DecoratedEntity Class
+ new DecoratedEntity(entity)
+ entity.get(name)
+ entity.set(name, value)
+ entity.set(attributes, options)
+ entity.at(at)
+ entity.at()
+ entity.by(by)
+ entity.by()
+ entity.seal(privateKey)
+ entity.seal()
+ entity.as(as)
+ entity.as()
+ entity.num(num)
+ entity.num()
+ entity.verify(publicKey)
+ entity.toValues()
Create a Entity instance
| Param | Type | Description |
| ----- | --- | -------- |
| args | * | |
Decorate an entity
| Param | Type | Description |
| ----- | --- | -------- |
| decorate | Entity | |
Detect a instance is entity or not
| Param | Type | Description |
| ----- | --- | -------- |
| obj | * | Object to check |
Constructor of DecoratedEntity class
| Param | Type | Description |
| ----- | --- | -------- |
| entity | Entity | Entity to decorate |
Get entity attribute.
| Param | Type | Description |
| ----- | --- | -------- |
| name | string | Name of attribute |
Set value
| Param | Type | Description |
| ----- | --- | -------- |
| name | string | Name of attribute to set |
| value | * | Value to set |
Set values
| Param | Type | Description |
| ----- | --- | -------- |
| attributes | Object | Attributes to set |
| options | Object | Optional settings |
| options.allowReserved | boolean | Allow to set reserved |
Set $$at attribute
| Param | Type | Description |
| ----- | --- | -------- |
| at | Date | Date data set at |
Get $$at attribute
Set $$by attribute
| Param | Type | Description |
| ----- | --- | -------- |
| by | string | Lump id |
Get $$by attribute
Seal this entity
| Param | Type | Description |
| ----- | --- | -------- |
| privateKey | string | Private key to seal |
Get seal
Set resource name as as
| Param | Type | Description |
| ----- | --- | -------- |
| as | string | As |
Get as
Set entity number as num
| Param | Type | Description |
| ----- | --- | -------- |
| num | string | As |
Get num
Verify the entity with public key
| Param | Type | Description |
| ----- | --- | -------- |
| publicKey | string | |
Convert into value object
License
-------
This software is released under the Apache-2.0 License.
Links
------
+ [ClayDB][clay_d_b_url]
+ [Realglobe, Inc.][realglobe,_inc__url]
[clay_d_b_url]: https://github.com/realglobe-Inc/claydb
[realglobe,_inc__url]: http://realglobe.jp