Supported platforms: Mini Program, Cloud Functions, Web
Query filter condition, indicating that a field is equal to a specific value. The eq command accepts a literal, which can be a number, boolean, string, object, array, or Date.
Parameters
value: any
Return Values
Command
Usage Instructions
For example, to filter all articles published by yourself, in addition to using the object-passing method:
const openID = 'xxx'
db.collection('articles').where({
_openid: openID
})
You can also use commands:
const _ = db.command
const openID = 'xxx'
db.collection('articles').where({
_openid: _.eq(openid)
})
Note that the eq command offers greater flexibility than the object method. It can be used to represent cases where a field equals a specific object. For example:
// This notation matches stat.publishYear == 2018 AND stat.language == 'zh-CN'
db.collection('articles').where({
stat: {
publishYear: 2018,
language: 'zh-CN'
}
})
// This notation means the stat object equals { publishYear: 2018, language: 'zh-CN' }
const _ = db.command
db.collection('articles').where({
stat: _.eq({
publishYear: 2018,
language: 'zh-CN'
})
})