微信小程序云开发服务端数据库API 指定筛选条件

Collection.where

指定筛选条件

方法签名如下:

function where(rule: object): Query

方法接受一个必填对象参数 rule,用于定义筛选条件

示例代码

找出未完成的进度 50 的待办事项:

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
exports.main = async (event, context) => {
  try {
    return await db.collection('todos').where({
      done: false,
      progress: 50
    })
    .get()
  } catch(e) {
    console.error(e)
  }
}

版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《微信小程序云开发服务端数据库API 指定筛选条件》
文章链接:https://zhuji.vsping.com/311734.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。