# Collection.field / Query.field / Document.field

Specifies the fields required to be returned by records in the returned results.

The method signature is shown as below:

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

The method accepts a required field to specify the field to return.

Sample code

The fields of description, done and progress are returned:

const db = wx.cloud.database()
db.collection('todos').field({
  description: true,
  done: true,
  progress: true
})
  .get()
  .then(console.log)
  .catch(console.error)
点击咨询小助手