SDK數(shù)據(jù)庫 Collection·索引

2020-07-27 14:28 更新

Collection

數(shù)據(jù)庫集合引用

方法

Collection.doc(id: string): Document

獲取集合中指定記錄的引用。方法接受一個 id 參數(shù),指定需引用的記錄的 _id。

Collection.add(options: Object): Promise<Object>

新增記錄,如果傳入的記錄對象沒有 _id 字段,則由后臺自動生成 _id;若指定了 _id,則不能與已有記錄沖突

Collection.aggregate(): Aggregate

發(fā)起聚合操作,定義完聚合流水線階段之后需調(diào)用 end 方法標志結(jié)束定義并實際發(fā)起聚合操作

Collection.count(): Promise<Object>

統(tǒng)計匹配查詢條件的記錄的條數(shù)

Collection.field(projection: Object): Collection

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

Collection.get(): Promise<Object>

獲取集合數(shù)據(jù),或獲取根據(jù)查詢條件篩選后的集合數(shù)據(jù)。

Collection.limit(value: number): Collection

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

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

指定查詢排序條件

Collection.remove(): Promise<Object>

刪除多條記錄。注意只支持通過匹配 where 語句來刪除,不支持 skip 和 limit。

Collection.skip(offset: number): Collection

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

Collection.update(): Promise<Object>

更新多條記錄

Collection.watch(options: Object): Object

監(jiān)聽集合中符合查詢條件的數(shù)據(jù)的更新事件。使用 watch 時,支持 where, orderBy, limit,不支持 field。

Collection.where(condition: Object): Collection

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


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號