operator
CloudBase Node SDK provides complete database operation capabilities. This article will focus on introducing query-related capabilities.
The db.command object is used to specify database operators. We generally define the command as follows for ease of use:
import cloudbase from "@cloudbase/node-sdk";
const app = cloudbase.init({
env: "your-env-id", // Replace with your environment id
});
const db = app.database();
const _ = db.command;
query operator
Field Update Operators
| operator | description | example |
|---|---|---|
set | set field value | _.set(value) |
inc | increment | _.inc(1) |
mul | multiply a numeric value | _.mul(2) |
remove | remove field | _.remove() |
push | append to array | _.push(value) |
pop | remove from end of array | _.pop() |
unshift | prepend to array | _.unshift(value) |
shift | remove from beginning of array | _.shift() |
