新聞中心
Command.eq(value: any): Command
支持端:小程序 , 云函數(shù) , Web
公司主營業(yè)務(wù):做網(wǎng)站、網(wǎng)站建設(shè)、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。成都創(chuàng)新互聯(lián)公司是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。成都創(chuàng)新互聯(lián)公司推出曲松免費做網(wǎng)站回饋大家。
查詢篩選條件,表示字段等于某個值。eq 指令接受一個字面量 (literal),可以是 number, boolean, string, object, array, Date。
參數(shù)
value: any
返回值
Command
使用說明
比如篩選出所有自己發(fā)表的文章,除了用傳對象的方式:
const openID = 'xxx'
db.collection('articles').where({
_openid: openID
})
還可以用指令:
const _ = db.command
const openID = 'xxx'
db.collection('articles').where({
_openid: _.eq(openid)
})
注意 eq 指令比對象的方式有更大的靈活性,可以用于表示字段等于某個對象的情況,比如:
// 這種寫法表示匹配 stat.publishYear == 2018 且 stat.language == 'zh-CN'
db.collection('articles').where({
stat: {
publishYear: 2018,
language: 'zh-CN'
}
})
// 這種寫法表示 stat 對象等于 { publishYear: 2018, language: 'zh-CN' }
const _ = db.command
db.collection('articles').where({
stat: _.eq({
publishYear: 2018,
language: 'zh-CN'
})
})
Command.neq(value: any): Command
支持端:小程序 , 云函數(shù) , Web
查詢篩選條件,表示字段不等于某個值。eq 指令接受一個字面量 (literal),可以是 number, boolean, string, object, array, Date。
參數(shù)
value: any
返回值
Command
使用說明
表示字段不等于某個值,和 eq 相反
Command.lt(value: any): Command
支持端:小程序 , 云函數(shù) , Web
查詢篩選操作符,表示需小于指定值??梢詡魅?nbsp;Date 對象用于進(jìn)行日期比較。
參數(shù)
value: any
返回值
Command
示例代碼
找出進(jìn)度小于 50 的 todo
const _ = db.command
db.collection('todos').where({
progress: _.lt(50)
})
.get({
success: console.log,
fail: console.error
})
Command.lte(value: any): Command
支持端:小程序 , 云函數(shù) , Web
查詢篩選操作符,表示需小于或等于指定值??梢詡魅?nbsp;Date 對象用于進(jìn)行日期比較。
參數(shù)
value: any
返回值
Command
示例代碼
找出進(jìn)度小于或等于 50 的 todo
const _ = db.command
db.collection('todos').where({
progress: _.lte(50)
})
.get({
success: console.log,
fail: console.error
})
Command.gt(value: any): Command
支持端:小程序 , 云函數(shù) , Web
查詢篩選操作符,表示需大于指定值。可以傳入 Date 對象用于進(jìn)行日期比較。
參數(shù)
value: any
返回值
Command
示例代碼
找出進(jìn)度大于 50 的 todo
const _ = db.command
db.collection('todos').where({
progress: _.gt(50)
})
.get({
success: console.log,
fail: console.error
})
Command.gte(value: any): Command
支持端:小程序 , 云函數(shù) , Web
查詢篩選操作符,表示需大于或等于指定值??梢詡魅?nbsp;Date 對象用于進(jìn)行日期比較。
參數(shù)
value: any
返回值
Command
示例代碼
找出進(jìn)度大于或等于 50 的 todo
const _ = db.command
db.collection('todos').where({
progress: _.gte(50)
})
.get({
success: console.log,
fail: console.error
})
Command.in(value: any[]): Command
支持端:小程序 , 云函數(shù) , Web
查詢篩選操作符,表示要求值在給定的數(shù)組內(nèi)。
參數(shù)
value: any[]
返回值
Command
示例代碼
找出進(jìn)度為 0 或 100 的 todo
const _ = db.command
db.collection('todos').where({
progress: _.in([0, 100])
})
.get({
success: console.log,
fail: console.error
})
Command.nin(value: any[]): Command
支持端:小程序 , 云函數(shù) , Web
查詢篩選操作符,表示要求值不在給定的數(shù)組內(nèi)。
參數(shù)
value: any[]
返回值
Command
示例代碼
找出進(jìn)度不是 0 或 100 的 todo
const _ = db.command
db.collection('todos').where({
progress: _.nin([0, 100])
})
.get({
success: console.log,
fail: console.error
}) 分享標(biāo)題:創(chuàng)新互聯(lián)小程序教程:SDK數(shù)據(jù)庫Command·查詢·比較操作符
分享地址:http://fisionsoft.com.cn/article/dhpjiss.html


咨詢
建站咨詢

