May 20, 2021 WeChat Mini Program Development Document
Get the record data, or get the record data that is filtered according to the query criteria
The function signature is as follows:
function get(): Promise<Result>
Returns a description of the value
The results of Promise's resolve and reject are defined as follows:
Description of the results | |
---|---|
resolve | The results of the query, the Result definition can be found below |
reject | The reason for the failure |
Result description
The result of the success callback and the result of Promise Resolve result are objects that are structured as follows:
Field | Type | Description |
---|---|---|
data | Object | The recorded data is an Object |
The sample code
Get my designated to-do details
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)
}
}