5.3.2.3. field

cloud.database.collection.field(definition)
参数
  • definition (object) – 用于指定需返回的字段

返回类型

Collection | Query | Document

返回

返回参数指定的字段

示例

返回 description, done 和 progress 三个字段

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
exports.main = async (event, context) => {
  try {
    return await db.collection('todos').field({
      description: true,
      done: true,
      progress: true
    }).get()
  } catch (e) {
    console.error(e)
  }
}