Query

Query

Perform CRUD operations on records inside Brinkee.

Kind: global class

new Query(tableName, [user])

Create a new instance of the Query class.

ParamTypeDescription
tableNamestringThe name of the table to perform operations on. If the table name is invalid, subsequent methods will throw.
[user]objectAn object containing the user that will be performing the operations. If omitted, all operations will be executed as the system user.

query.createOne(payload) ⇒ object

Create a record

Kind: instance method of Query
Returns: object - The created record

ParamType
payloadObject

Example

const newTask = await new Query("task").createOne({ subject: "My new task", });
// newTask.uid contains the `uid` of the newly created task

query.readOneByUid(uid) ⇒ object

Query a record by uid, this is just a wrapper around readOne("uid=" + uid);

Kind: instance method of Query

ParamType
uidstring

Example

const task = await new Query("task").readOneByUid("my_uid");

query.readOne(filter) ⇒ object

Query a record by filter

Kind: instance method of Query

ParamType
filterstring

query.readMany(filter, limit, sort) ⇒ Array

Query multiple records by filter. Sets a filter and a sorting method.

Kind: instance method of Query

ParamType
filterstring
limitnumber
sortstring

Example

const records = await new Query("record").readMany(`name=Brinkee`);

query.updateOneByUid(uid, payload) ⇒ Promise.<{}>

Update one record by uid.

Kind: instance method of Query

ParamType
uidstring
payloadobject

Example

const updated = await new Query("task").updateOneByUid(uid, { active: true })

query.updateOne(filter, payload) ⇒ object

Update one record using a filter

Kind: instance method of Query
Returns: object - Updated data

ParamType
filterstring
payloadobject

Example

const updated = await new Query("record").updateOne("name=Brinkee", { state: published });

query.deleteOneByUid(uid) ⇒ Promise.<void>

Deletes one record by id

Kind: instance method of Query

ParamType
uidstring

Example

await new Query("task").deleteOnyByUid(uid);

query.deleteOne(filter) ⇒ Promise.<void>

Deletes one record using a filter.

Kind: instance method of Query

ParamType
filterstring

Example

await new Query("task").deleteOne("uid=some_uid")