想实现这样的sql语句,做个统计:
select a.*,(select count(1) from fabulous b where a._id=b.clockrecordid and _openid='123456789') as z from clockrecord a
order by a.time desc
表1:clockrecord
字段有:_id,name....
表2:fabulous
字段有:clockrecordid,_openid,_id
在云开发中,我这样使用:
const db = wx.cloud.database();
const result = db.collection('clockrecord').aggregate()
.lookup({
from: 'fabulous',
localField: '_id',
foreignField: 'clockrecordid',
as: 'z'
})
.end()
.then(res => console.log(res))
.catch(err => console.error(err))
提示: [sm]:40 Error: errCode: -502003 database permission denied | errMsg: Permission denied
两张表的权限均是所有用户可读,创建者可读写
云环境权限是未登陆用户可访问。
求救应该如何写?
你好,检查下数据库的权限,权限问题