冉娃娃
冉娃娃
  • 发布:2025-08-06 21:23
  • 更新:2025-08-07 09:43
  • 阅读:32

JQL调试器查询后提示:未能获取当前用户信息:当前用户为匿名身份

分类:HBuilderX

JQL语法如下:

db.collection('ledgers').add({  
    "user_id": "688dd455bd02209f5b5ba6b3",  
    "event_id": "688dccd73d029cca22338f90",  
    "event_name": "其他庆典",  
    "name": "零星礼薄"  
})

legders.schema.json如下:

{  
    "bsonType": "object",  
    "required": [  
        "user_id",  
        "event_id",  
        "name",  
        "event_name"  
    ],  
    "permission": {  
        "read": "doc.user_id == auth.uid",  
        "create": "auth.uid != null",  
        "update": "doc.user_id == auth.uid",  
        "delete": "doc.user_id == auth.uid"  
    },  
    "properties": {  
        "_id": {  
            "description": "主键,由系统自动生成"  
        },  
        "user_id": {  
            "bsonType": "string",  
            "description": "用户ID,关联uni-id-users表",  
            "foreignKey": "uni-id-users._id",  
            "forceDefaultValue": {  
                "$env": "uid"  
            }  
        },  
        "event_id": {  
            "bsonType": "string",  
            "description": "事件ID,关联events表",  
            "foreignKey": "events._id"  
        },  
        "event_name": {  
            "bsonType": "string",  
            "description": "事件名称",  
            "title": "事件名称",  
            "foreignKey": "events.name"  
        },  
        "name": {  
            "bsonType": "string",  
            "minLength": 1,  
            "maxLength": 20,  
            "description": "名称",  
            "title": "名称",  
            "trim": "both",  
            "errorMessage": {  
                "required": "礼薄名称必须填写",  
                "minLength": "礼薄名称最少1个字",  
                "maxLength": "礼薄名称不能超过20个字"  
            }  
        }  
    }  
}

报错截图

官方文档

官方文档说JQL调试器不受权限影响,那会是什么原因引起的?

2025-08-06 21:23 负责人:无 分享
已邀请:
DCloud_UNI_yuhe

DCloud_UNI_yuhe

应该是这里 forceDefaultValue ,会需要传入用户信息导致的

  • 冉娃娃 (作者)

    确实是user_id字段导致的

    但把他换成defaultValue同样报错

    去掉defaultValue之后就好了


    可是为什么换成defaultValue还要报错呢,明明我已经指定了user_id,jql就不应该去获取默认值了呀

    2025-08-08 21:48

要回复问题请先登录注册