日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)小程序教程:SDK數(shù)據(jù)庫(kù)Collection·構(gòu)建查詢條件

Collection.where(condition: Object): Collection

支持端:小程序 , 云函數(shù) , Web

指定查詢條件,返回帶新查詢條件的新的集合引用

參數(shù)

condition: Object

查詢條件

返回值

Collection

示例代碼

const _ = db.command
const result = await db.collection('todos').where({
  price: _.lt(100)
}).get()


Collection.limit(value: number): Collection

支持端:小程序 , 云函數(shù) , Web

指定查詢結(jié)果集數(shù)量上限

參數(shù)

value: number

返回值

Collection

說明

limit 在小程序端默認(rèn)及最大上限為 20,在云函數(shù)端默認(rèn)及最大上限為 1000

示例代碼

db.collection('todos').limit(10)
  .get()
  .then(console.log)
  .catch(console.error)

Collection.orderBy(fieldPath: string, string: order): Collection

支持端:小程序 , 云函數(shù) , Web

指定查詢排序條件

參數(shù)

fieldPath: string

string: order

返回值

Collection

說明

方法接受一個(gè)必填字符串參數(shù) fieldName 用于定義需要排序的字段,一個(gè)字符串參數(shù) order 定義排序順序。order 只能取 asc 或 desc。

如果需要對(duì)嵌套字段排序,需要用 "點(diǎn)表示法" 連接嵌套字段,比如 style.color 表示字段 style 里的嵌套字段 color。

同時(shí)也支持按多個(gè)字段排序,多次調(diào)用 orderBy 即可,多字段排序時(shí)的順序會(huì)按照 orderBy 調(diào)用順序先后對(duì)多個(gè)字段排序

示例代碼:按一個(gè)字段排序

按進(jìn)度排升序取待辦事項(xiàng)

db.collection('todos').orderBy('progress', 'asc')
  .get()
  .then(console.log)
  .catch(console.error)

示例代碼:按多個(gè)字段排序

先按 progress 排降序(progress 越大越靠前)、再按 description 排升序(字母序越前越靠前)取待辦事項(xiàng):

db.collection('todos')
  .orderBy('progress', 'desc')
  .orderBy('description', 'asc')
  .get()
  .then(console.log)
  .catch(console.error)

Collection.skip(offset: number): Collection

支持端:小程序 , 云函數(shù) , Web

指定查詢返回結(jié)果時(shí)從指定序列后的結(jié)果開始返回,常用于分頁(yè)

參數(shù)

offset: number

返回值

Collection

示例代碼

db.collection('todos').skip(10)
  .get()
  .then(console.log)
  .catch(console.error)

Collection.field(projection: Object): Collection

支持端:小程序 , 云函數(shù) , Web

指定返回結(jié)果中記錄需返回的字段

參數(shù)

projection: Object

返回值

Collection

說明

方法接受一個(gè)必填對(duì)象用于指定需返回的字段,對(duì)象的各個(gè) key 表示要返回或不要返回的字段,value 傳入 true|false(或 1|-1)表示要返回還是不要返回。

示例代碼

只返回 description, done 和 progress 三個(gè)字段:

db.collection('todos').field({
  description: true,
  done: true,
  progress: true,
})
  .get()
  .then(console.log)
  .catch(console.error)

網(wǎng)頁(yè)標(biāo)題:創(chuàng)新互聯(lián)小程序教程:SDK數(shù)據(jù)庫(kù)Collection·構(gòu)建查詢條件
文章源于:http://www.dlmjj.cn/article/djoeiso.html