1***@163.com
1***@163.com
  • 发布:2021-06-22 16:19
  • 更新:2021-06-23 08:47
  • 阅读:444

【报Bug】parentKey在连接云端云函数环境时报错!但本地云函数环境又没问题。

分类:uniCloud

产品分类: uniCloud/App

示例代码:

company-list.schema.json文件

{  
    "bsonType": "object",  
    "required": ["name", "desc", "type",  
        "admin_id", "print_desc"  
    ],  
    "permission": {  
        "read": true,  
        "create": true,  
        "update": true,  
        "delete": false  
    },  
    "properties": {  
        "_id": {  
            "description": "ID,系统自动生成"  
        },  
        "name": {  
            "bsonType": "string",  
            "label": "公司名称",  
            "errorMessage": {  
                "required": "{label}不能为空",  
                "format": "{label}格式无效"  
            },  
            "order": 1,  
            "trim": "both"  
        },  
        "desc": {  
            "bsonType": "string",  
            "label": "工号缩写",  
            "errorMessage": {  
                "required": "{label}不能为空",  
                "format": "{label}格式无效"  
            },  
            "order": 1,  
            "trim": "both"  
        },  
        "print_desc": {  
            "bsonType": "string",  
            "label": "打印别名",  
            "errorMessage": {  
                "required": "{label}不能为空",  
                "format": "{label}格式无效"  
            },  
            "order": 1,  
            "trim": "both"  
        },  
        "enable": {  
            "bsonType": "bool",  
            "label": "是否启用",  
            "defaultValue": true,  
            "order": 1  
        },  
        "sort": {  
            "bsonType": "int",  
            "label": "排序",  
            "defaultValue": 100,  
            "description": "按照大小升序,小值在前 (asc)",  
            "order": 1  
        },  
        "type": {  
            "bsonType": "int",  
            "label": "类型",  
            "errorMessage": {  
                "required": "{label}不能为空",  
                "format": "{label}格式无效"  
            },  
            "order": 2,  
            "enum": [{  
                    "text": "总部",  
                    "value": 0  
                }, {  
                    "text": "分公司",  
                    "value": 1  
                },  
                {  
                    "text": "子公司",  
                    "value": 2  
                }  
            ],  
            "exclusiveMinimum": true,  
            "exclusiveMaximum": true  
        },  
        "parent_id": {  
            "bsonType": "string",  
            "label": "父公司",  
            "errorMessage": {  
                "format": "{label}格式无效"  
            },  
            "order": 3,  
            "trim": "both",  
            "parentKey": "_id"  
        },  
        "admin_id": {  
            "bsonType": "array",  
            "label": "绑定的管理员",  
            "errorMessage": {  
                "required": "{label}不能为空",  
                "format": "{label}格式无效"  
            },  
            "order": 4,  
            "description": "公司对应的管理员账号ID",  
            "trim": "both",  
            "foreignKey": "uni-id-users._id"  
        }  
    }  
}

操作步骤:
return db.collection("company-list").parentKey("parent_id").where("enable==true").orderBy("sort asc,_id asc").get({  
                getTree: {  
                    startWith:"admin_id=='60ace410acc1cf0001c88031'"  
                }  
            }).then(res => {  
                return Promise.resolve(res.result.data)  
            }).catch(err => {  
                return Promise.reject(err)  
            })

预期结果:

连接云端云函数时也返回正常的数据

实际结果:

连接本地云函数时返回正常的数据,但在云端云函数时会报错。

bug描述:

连接云端云函数时parentKey设置无效

2021-06-22 16:19 负责人:无 分享
已邀请:
DCloud_uniCloud_JSON

DCloud_uniCloud_JSON

遇到本地没问题,云端有问题。首先需要怀疑是不是没有上传导致的

  • 1***@163.com (作者)

    上传好多次了,就是不行。我确定云端和本地的schema是一致的,不论是从编辑器下载下来还是从控制台直接看数据库schema文件,都是一致的

    2021-06-23 08:43

1***@163.com

1***@163.com (作者)

问题解决了,昨天上传了不生效,今天上传又好了。不知道具体是什么导致的,现在正常了。

  • DCloud_uniCloud_WYQ

    昨天确实有一小段时间有问题,我们发现之后立即修复了

    2021-06-23 10:43

该问题目前已经被锁定, 无法添加新回复