Query
Query
Perform CRUD operations on records inside Brinkee.
Kind: global class
- Query
- new Query(tableName, [user])
- .createOne(payload) ⇒
object
- .readOneByUid(uid) ⇒
object
- .readOne(filter) ⇒
object
- .readMany(filter, limit, sort) ⇒
Array
- .updateOneByUid(uid, payload) ⇒
Promise.<{}>
- .updateOne(filter, payload) ⇒
object
- .deleteOneByUid(uid) ⇒
Promise.<void>
- .deleteOne(filter) ⇒
Promise.<void>
new Query(tableName, [user])
Create a new instance of the Query class.
Param | Type | Description |
---|---|---|
tableName | string | The name of the table to perform operations on. If the table name is invalid, subsequent methods will throw. |
[user] | object | An 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
Param | Type |
---|---|
payload | Object |
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
Param | Type |
---|---|
uid | string |
Example
const task = await new Query("task").readOneByUid("my_uid");
query.readOne(filter) ⇒ object
Query a record by filter
Kind: instance method of Query
Param | Type |
---|---|
filter | string |
query.readMany(filter, limit, sort) ⇒ Array
Query multiple records by filter. Sets a filter and a sorting method.
Kind: instance method of Query
Param | Type |
---|---|
filter | string |
limit | number |
sort | string |
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
Param | Type |
---|---|
uid | string |
payload | object |
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
Param | Type |
---|---|
filter | string |
payload | object |
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
Param | Type |
---|---|
uid | string |
Example
await new Query("task").deleteOnyByUid(uid);
query.deleteOne(filter) ⇒ Promise.<void>
Deletes one record using a filter.
Kind: instance method of Query
Param | Type |
---|---|
filter | string |
Example
await new Query("task").deleteOne("uid=some_uid")