云开发数据库联表查询无权限
发布于 6 年前 作者 yanghan 14012 次浏览 来自 问答

const db = wx.cloud.database()
    db.collection('pets')
    .get() 
    .then(res => {
      console.log(res)
      this.setData({
        pets: res.data
      })
    })
const db = wx.cloud.database()
    db.collection('shop')
    .get() 
    .then(res => {
      console.log(res)
      this.setData({
        pets: res.data
      })
    })

正常查询都没问题

const db = wx.cloud.database()
    db.collection('pets').aggregate()
    .lookup({
      from: 'shop',
      localField: 'shopId',
      foreignField: '_id',
      as: 'shop'
    })
    .end() 
    .then(res => {
      console.log(res)
      this.setData({
        pets: res.data
      })
    })
      .catch(err => console.error(err))

联表查询就报没权限了

VM490:1 Error: errCode: -502003 database permission denied | errMsg: Permission denied
    at new u (WAService.js:1)
    at Function.success (WAService.js:1)
    at Object.success (WAService.js:1)
    at r (WAService.js:1)
    at WAService.js:1
    at v (WAService.js:1)
    at WAService.js:1
    at t.<anonymous> (VM504 asdebug.js:1)
    at WAService.js:1
    at WAService.js:1
3 回复

不支持小程序端,在云函数里使用吧

回到顶部