# 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 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)
  }
}