我猜测可能是没有使用异步,于是写了个云函数用async来调用就好了。同时也解决了权限问题,之前因为password字段没有修改为string型,所以查询也出了问题。
原本代码:
const db=uniCloud.database();
var User=db.collection("tiezi").where('user_id==$cloudEnv_uid').get();
console.log(User);
修改后:
uniCloud.callFunction({
name:"Users",
data:{
_id:db.getCloudEnv('$cloudEnv_uid')
}
}
).then(res=>{
let user=res.result.data
console.log(user);
})