# Document.get

Gets record data or gets record data filtered by query condition.

Function signature is shown as below:

function get(): Promise<Result>

Description of return value

The results of resolve and reject for Promise are defined as below:

Result Description
resolve The result of query. The Result is defined as below.
reject Reason for failure

Result description

The result of success callback and Result of resolve for Promise are objects with the following structure:

Field Type Description
data Object Record data, an object

Sample code

Get details of my designated to-do list

Promise style

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
exports.main = async (event, context) => {
  try {
    return await db.collection('todos').doc('<some-todo-id>').get()
  } catch(e) {
    console.error(e)
  }
}