clay-driver-json
Clay driver to save data into JSON files
Installation
$ npm install clay-driver-json --save
Usage
'use strict' const JSONDriver = const clayLump = let lump01 = /* ... */
API
clay-driver-json@4.0.16
Clay driver to save data into JSON files
- Functions
JSONDriver
Class
Functions
JSONDriver
create(args) -> Create driver instance
Param | Type | Description |
---|---|---|
args | * |
JSONDriver
Class
Driver to store data into json files
Extends:
Driver
new JSONDriver(dirname, options)
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 |
Promise
driver.flush() -> Flush data into json files
Promise.<ClayEntity>
driver.one(resourceName, id) -> Get single entity from resource
Param | Type | Description |
---|---|---|
resourceName | string | Name of resource |
id | ClayId | Resource id |
Promise.<ClayCollection>
driver.list(resourceName, condition) -> List entities from resource
Param | Type | Description |
---|---|---|
resourceName | string | Name of resource |
condition | ListCondition | List condition query |
Promise.<ClayEntity>
driver.create(resourceName, attributes) -> Create a new entity with resource
Param | Type | Description |
---|---|---|
resourceName | string | Name of resource |
attributes | Object | Resource attributes to create |
Promise.<ClayEntity>
driver.update(resourceName, id, attributes) -> Update an existing entity in resource
Param | Type | Description |
---|---|---|
resourceName | string | Name of resource |
id | ClayId | Resource id |
attributes | Object | Resource attributes to update |
Promise.<number>
driver.destroy(resourceName, id) -> Delete a entity resource
Param | Type | Description |
---|---|---|
resourceName | string | Name of resource |
id | ClayId | Resource id |
Promise.<boolean>
driver.drop(resourceName) -> Drop resource
Param | Type | Description |
---|---|---|
resourceName | string | Name of resource |
Promise.<Resource>
driver.resources() -> List resources
License
This software is released under the Apache-2.0 License.