// 云函数模板
// 部署:在 cloud-functions/login 文件夹右击选择 “上传并部署”
const cloud = require('wx-server-sdk')
// 初始化 cloud
cloud.init({
// // API 调用都保持和云函数当前所在环境一致
// env: cloud.DYNAMIC_CURRENT_ENV
})
const db = cloud.database()
var _id = ''
/**
* 这个示例将经自动鉴权过的小程序用户 openid 返回给小程序端
*
* event 参数包含小程序端调用传入的 data
*
*/
exports.main = async (event, context) => {
// var _id = 'zhang'
let _id = await db.collection('all_user_table').where({
username:event.username,
password:event.password
}).get({
success:function(res){
}
})
return _id.result.data[0]._id
}
使用赋值才能then()