import cloudbase from "@cloudbase/js-sdk";const app = cloudbase.init({env: "your-env-id", // Replace with your environment id});const models = app.models;
models.modelName.get(options);
Parameter | Type | Required | Description |
filter.where | object | No | query conditions |
select | object | Yes | Specifying the fields to return |
// Query the record with _id 'todo-id-123' from the todo data model.const todo = await models.todo.get({filter: {where: {_id: {$eq: "todo-id-123",},},},select: {$master: true, // Return all fields},});console.log("Query result:", todo.data);
{data: {records: [{_id: "todo-id-123",title: "Server-side Task",completed: false,// ... Other fields}],total: 1}}
models.modelName.list(options);
Parameter | Type | Required | Description |
filter.where | object | No | query conditions |
select | object | Yes | Specifying the fields to return |
// Query records from the todo data model where completed is false.const todos = await models.todo.list({filter: {where: {completed: {$eq: false},},},});console.log("Query result:", todos.data);
{data: {records: [{_id: "todo-id-1",title: "Task 1",completed: false},{_id: "todo-id-2",title: "Task 2",completed: false}],total: 2}}
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback