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 |
不支持小程序端,在云函数里使用吧
没细看 版本要求:
wx-server-sdk
1.3.0
或以上 不支持在小程序端使用,结果折腾半天。。哭死
联表查询不支持小程序端
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database/join.html