方法签名:
function gt(value: number): Command
示例代码
找出进度大于 50 的 todo
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
try {
return await db.collection('todos').where({
progress: _.gt(50)
})
.get()
} catch(e) {
console.error(e)
}
}
db.command.gte
查询筛选条件,表示字段需大于或等于指定值。
方法签名:
function gte(value: number): Command
示例代码
找出进度大于或等于 50 的 todo
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
try {
return await db.collection('todos').where({
progress: _.gte(50)
})
.get()
} catch(e) {
console.error(e)
}
}
db.command.in
查询筛选条件,表示字段的值需在给定的数组内。
方法签名:
function in(values: any[]): Command
示例代码
找出进度为 0 或 100 的 todo
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
try {
return await db.collection('todos').where({
progress: _.in([0, 100])
})
.get()
} catch(e) {
console.error(e)
}
}
db.command.in
查询筛选条件,表示字段的值需不在给定的数组内。
方法签名:
function nin(values: any[]): Command
示例代码
找出进度不是 0 或 100 的 todo
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
try {
return await db.collection('todos').where({
progress: _.nin([0, 100])
})
.get()
} catch(e) {
console.error(e)
}
}
db.command.nin
支持端:小程序 , 云函数 , Web查询筛选操作符,表示要求值不在给定的数组内。
参数
value: any[]
返回值
Command
示例代码
找出进度不是 0 或 100 的 todo
const _ = db.command
db.collection('todos').where({
progress: _.nin([0, 100])
})
.get({
success: console.log,
fail: console.error
})
标签:微信小程序
相关阅读 >>
微信小程序云开发服务端数据库api 指定返回结果中记录需返回的字段
更多相关阅读请进入《微信小程序》频道 >>

Vue.js 设计与实现 基于Vue.js 3 深入解析Vue.js 设计细节
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者