Collection.field(projection: Object): Collection

支持端:小程序 , 云函数 , Web

指定返回结果中记录需返回的字段

参数

projection: Object

返回值

Collection

说明

方法接受一个必填对象用于指定需返回的字段,对象的各个 key 表示要返回或不要返回的字段,value 传入 true|false(或 1|-1)表示要返回还是不要返回。

示例代码

只返回 description, done 和 progress 三个字段:

  1. db.collection('todos').field({
  2. description: true,
  3. done: true,
  4. progress: true,
  5. })
  6. .get()
  7. .then(console.log)
  8. .catch(console.error)