官方视频无法使用于是考虑自己写连表
get_database() {
let db = uniCloud.databaseForJQL()
let uid = uniCloud.getCurrentUserInfo().uid
console.log(uid)
let a = db.collection('liuyanban').where({
$or: [{
state: true
},
{
user_id: uid
}
]
}).getTemp();
let b = db.collection('uni-id-users').field('_id, nickname, avatar_file').
getTemp();
db.collection(a,b).get()
}
然后这个是schema
// 文档教程: https://uniapp.dcloud.net.cn/uniCloud/schema
{
"bsonType": "object",
"required": [],
"permission": {
"read": "doc.state == true || doc.user_id == auth.uid",
"create": "auth.uid != null",
"update": false,
"delete": false
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"text": {
"bsonType": "string"
},
"state": {
"bsonType": "bool",
"forceDefaultValue":false
},
"user_id": {
"foreignKey": "uni-id-users._id",
"bsonType": "string",
"forceDefaultValue":{
"$env": "uid"
}
},
"uid": {
"bsonType": "string",
"forceDefaultValue":{
"$env": "uid"
}
}
}
}
read改成true就可以
0 个回复