Collection.field / Query.field / Document.field

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

方法签名如下:

  1. function field(definition: object): Collection | Query | Document

方法接受一个必填字段用于指定需返回的字段

示例代码

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

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

原文: https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-client-api/database/collection.field.html