cxUserspace

cxUserspace

Create, Read, Update & Delete from the Userspace Database

Example

const cxUserspace = require('cxUserspace');
async function main(data) {
  var result = await cxUserspace.read(data.routing.dest_number);
  // Do something with result
  return data
}

Methods

(static) create(area, key, data) → {Promise}

Source:

Create Record

Example
await cxUserspace.create('myDatabase', 1, {value: 'Hello World!'})
Parameters:
Name Type Description
area string

Datastore Name

key string | number

Row Id

data object

Data Object / Row

Returns:
Type
Promise

(static) delete(area, key) → {Promise}

Source:

Delete Record

Example
await cxUserspace.delete('myDatabase', 1)
Parameters:
Name Type Description
area string

Datastore Name

key string | number

Row Id

Returns:
Type
Promise

(static) knex(database, tablenullable) → {Object}

Source:

Get Knex Instance - Calling this function will return an instance of Knex (https://knexjs.org) The first parameter you specify the database name "default" should be your first param. Optionally the second parameter contains the table name

Example
const qry = await cxUserspace.knex('myDatabase', 'myTable')
Parameters:
Name Type Attributes Description
database string

Datastore Name

table string <nullable>

Table Name

Returns:
Type
Object

(static) read(read, key) → {Promise.<object>}

Source:

Create Record

Example
var data = await cxUserspace.read('myDatabase', 1)
Parameters:
Name Type Description
read string

Datastore Name

key string | number

Row Id

Returns:
Type
Promise.<object>

(static) update(area, key, data) → {Promise}

Source:

Update Record

Example
await cxUserspace.update('myDatabase', 1, {value: 'Hello World!'})
Parameters:
Name Type Description
area string

Datastore Name

key string | number

Row Id

data object

Data Object / Row

Returns:
Type
Promise