1***@qq.com
1***@qq.com
  • 发布:2024-11-22 18:00
  • 更新:2024-11-22 18:00
  • 阅读:51

留言板权限校验未通过

分类:uniCloud

官方视频无法使用于是考虑自己写连表

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就可以

2024-11-22 18:00 负责人:无 分享
已邀请:

要回复问题请先登录注册