4.1.9 • Published 5 years ago

clay-driver-base v4.1.9

Weekly downloads
400
License
Apache-2.0
Repository
github
Last release
5 years ago

clay-driver-base

Build Status npm Version JS Standard

Base driver for clay

Installation

$ npm install clay-driver-base --save

Usage

'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

clay-driver-base@4.1.8

Base driver for clay

Functions

create(args) -> Driver

Create driver instance

ParamTypeDescription
args*

Driver Class

Abstract driver

new Driver()

Constructor of Driver class

driver.one(resourceName, id, options) -> Promise.<ClayEntity>

Get single entity from resource

ParamTypeDescription
resourceNamestringName of resource
idClayIdResource id
optionsObjectOptions settings

driver.list(resourceName, condition, options) -> Promise.<ClayCollection>

List entities from resource

ParamTypeDescription
resourceNamestringName of resource
conditionListConditionList condition query
optionsObjectOptions settings

driver.create(resourceName, attributes) -> Promise.<ClayEntity>

Create a new entity with resource

ParamTypeDescription
resourceNamestringName of resource
attributesObjectResource attributes to create

driver.update(resourceName, id, attributes) -> Promise.<ClayEntity>

Update an existing entity in resource

ParamTypeDescription
resourceNamestringName of resource
idClayIdResource id
attributesObjectResource attributes to update

driver.destroy(resourceName, id) -> Promise.<number>

Delete a entity resource

ParamTypeDescription
resourceNamestringName of resource
idClayIdResource id

driver.drop(resourceName) -> Promise.<boolean>

Drop resource

ParamTypeDescription
resourceNamestringName of resource

driver.resources() -> Promise.<Resource>

List resources

License

This software is released under the Apache-2.0 License.

Links

4.1.8

5 years ago

4.1.9

5 years ago

4.1.7

6 years ago

4.1.6

6 years ago

4.1.5

7 years ago

4.1.4

7 years ago

4.1.3

7 years ago

4.1.2

7 years ago

4.1.1

7 years ago

4.0.1

8 years ago

3.1.3

8 years ago

3.1.2

8 years ago

3.1.0

8 years ago

3.0.1

8 years ago