May 20, 2021 WeChat Mini Program Development Document
The object contains a geo-location constructor.
The owning fields are as follows:
Field | Description |
---|---|
Point | Location point |
Construct a geographic location. Can be used to query criteria, update field values, or add field values when records are added.
The method signature is as follows:
function Point(longitude: number, latitude: number): Point
Method accepts two required parameters, the first is longitude and the second is latitude, so it is important to pay attention to the order
The sample code
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
exports.main = async (event, context) => {
try {
return await db.collection('todos').add({
description: 'eat an apple',
location: new db.Geo.Point(113, 23)
})
} catch(e) {
console.error(e)
}
}