Clay driver to save data into JSON files
npm install clay-driver-jsonclay-driver-json
==========
[![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-json
[bd_travis_url]: http://travis-ci.org/realglobe-Inc/clay-driver-json
[bd_travis_shield_url]: http://img.shields.io/travis/realglobe-Inc/clay-driver-json.svg?style=flat
[bd_travis_com_url]: http://travis-ci.com/realglobe-Inc/clay-driver-json
[bd_travis_com_shield_url]: https://api.travis-ci.com/realglobe-Inc/clay-driver-json.svg?token=
[bd_license_url]: https://github.com/realglobe-Inc/clay-driver-json/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/realglobe-Inc/clay-driver-json
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/realglobe-Inc/clay-driver-json.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/realglobe-Inc/clay-driver-json.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/realglobe-Inc/clay-driver-json
[bd_gemnasium_shield_url]: https://gemnasium.com/realglobe-Inc/clay-driver-json.svg
[bd_npm_url]: http://www.npmjs.org/package/clay-driver-json
[bd_npm_shield_url]: http://img.shields.io/npm/v/clay-driver-json.svg?style=flat
[bd_standard_url]: http://standardjs.com/
[bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
Clay driver to save data into JSON files
Installation
-----
``bash`
$ npm install clay-driver-json --save
Usage
---------
`javascript
'use strict'
const { JSONDriver } = require('clay-driver-memory')
{
const clayLump = require('clay-lump')
let lump01 = clayLump({
driver: new JSONDriver({})
})
/ ... /
}
`
API
---------
Clay driver to save data into JSON files
+ Functions
+ create(args)
+ JSONDriver Class
+ new JSONDriver(dirname, options)
+ driver.flush()
+ driver.one(resourceName, id)
+ driver.list(resourceName, condition)
+ 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 | * | |
ClassDriver to store data into json files
Extends:
+ Driver`
Constructor of JSONDriver class
| Param | Type | Description |
| ----- | --- | -------- |
| dirname | string | Directory name to save data |
| options | Object | Optional settings |
| options.flashInterval | number | Interval of auto flush |
Flush data into json files
Get single entity from resource
| Param | Type | Description |
| ----- | --- | -------- |
| resourceName | string | Name of resource |
| id | ClayId | Resource id |
List entities from resource
| Param | Type | Description |
| ----- | --- | -------- |
| resourceName | string | Name of resource |
| condition | ListCondition | List condition query |
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