# Collection.where

Specifies filter conditions.

The method signature is shown as below:

function where(rule: object): Query

The method accepts a required object parameter rule to define the filter conditions.

Sample code

Find out the unfinished to-dos whose progress is 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)
  }
}
点击咨询小助手