按照文档
// 客户端联表查询
const db = uniCloud.database()
const order = db.collection('order').field('book_id,quantity').getTemp()
const book = db.collection('book').field('_id,title as book_title,author as book_author').getTemp()
db.collection(order, book)
.where('book_id.book_title == "三国演义"') // 如果field内对副表字段title进行了重命名,where方法内则需要使用重命名之后的字段名
.get()
.then(res => {
console.log(res);
}).catch(err => {
console.error(err)
})
我的代码
userinfo.value = uni.getStorageSync('userinfo')
const activity = db.collection('activity').skip(pageNum.value - 1 * pageSize).limit(pageSize).field('name, start_time, end_time, cover, location, create_user').getTemp()
const user = db.collection('user').field('_id, nick, avatar').getTemp()
db.collection(activity, user).get()
.then((res) => console.log(res))
.catch((err) => console.error(err))
但是db.collection提示直接收一个string参数(如附件截图)