Base driver for clay
npm install clay-driver-baseclay-driver-base
==========
[![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-driver-base
[bd_travis_url]: http://travis-ci.org/realglobe-Inc/clay-driver-base
[bd_travis_shield_url]: http://img.shields.io/travis/realglobe-Inc/clay-driver-base.svg?style=flat
[bd_travis_com_url]: http://travis-ci.com/realglobe-Inc/clay-driver-base
[bd_travis_com_shield_url]: https://api.travis-ci.com/realglobe-Inc/clay-driver-base.svg?token=
[bd_license_url]: https://github.com/realglobe-Inc/clay-driver-base/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/realglobe-Inc/clay-driver-base
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/realglobe-Inc/clay-driver-base.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/realglobe-Inc/clay-driver-base.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/realglobe-Inc/clay-driver-base
[bd_gemnasium_shield_url]: https://gemnasium.com/realglobe-Inc/clay-driver-base.svg
[bd_npm_url]: http://www.npmjs.org/package/clay-driver-base
[bd_npm_shield_url]: http://img.shields.io/npm/v/clay-driver-base.svg?style=flat
[bd_standard_url]: http://standardjs.com/
[bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
Base driver for clay
Installation
-----
``bash`
$ npm install clay-driver-base --save
Usage
---------
`javascript
'use strict'
const {Driver} = require('clay-driver-base')
// Define custom driver
class MyDriver extends Driver {
one (namespace, id) { / ... / }
list (namespace, condition) { / ... / }
create (namespace, attributes) { / ... / }
update (namespace, id, attributes) { / ... / }
destroy (namespace, id) { / ... / }
}
{
const clayLump = require('clay-lump')
const lump01 = clayLump({
driver: new MyDriver({/ ... /})
})
/ ... /
}
`
For more detail, see API Guide
API
---------
Base driver for clay
+ Functions
+ create(args)
+ Driver Class
+ new Driver()
+ driver.one(resourceName, id, options)
+ driver.list(resourceName, condition, options)
+ driver.create(resourceName, attributes)
+ driver.update(resourceName, id, attributes)
+ driver.destroy(resourceName, id)
+ driver.drop(resourceName)
+ driver.resources()
Create driver instance
| Param | Type | Description |
| ----- | --- | -------- |
| args | * | |
Abstract driver
Constructor of Driver class
Get single entity from resource
| Param | Type | Description |
| ----- | --- | -------- |
| resourceName | string | Name of resource |
| id | ClayId | Resource id |
| options | Object | Options settings |
List entities from resource
| Param | Type | Description |
| ----- | --- | -------- |
| resourceName | string | Name of resource |
| condition | ListCondition | List condition query |
| options | Object | Options settings |
Create a new entity with resource
| Param | Type | Description |
| ----- | --- | -------- |
| resourceName | string | Name of resource |
| attributes | Object | Resource attributes to create |
Update an existing entity in resource
| Param | Type | Description |
| ----- | --- | -------- |
| resourceName | string | Name of resource |
| id | ClayId | Resource id |
| attributes | Object | Resource attributes to update |
Delete a entity resource
| Param | Type | Description |
| ----- | --- | -------- |
| resourceName | string | Name of resource |
| id | ClayId | Resource id |
Drop resource
| Param | Type | Description |
| ----- | --- | -------- |
| resourceName | string | Name of resource |
List resources
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