2***@qq.com
2***@qq.com
  • 发布:2023-03-22 10:03
  • 更新:2023-03-22 11:19
  • 阅读:451

【报Bug】联表查询新旧写法表现不一致 无法返回关联字段

分类:uniCloud

产品分类: uniCloud/App

示例代码:

已上传附件 在JQL查询.jql文件中已准备好查询代码

操作步骤:

提供的数据导入云空间后运行uniapp,
JQL查询.jql文件中的预期结果和实际结果下的代码分别F5执行

预期结果:

    {  
        "_id": "641818baf5cf3a3e09971cd0",  
        "create_time": 1679300789398,  
        "group_admins": [  
            {  
                "_id": "6418170509e29881605a2c4f",  
                "avatar": "",  
                "comment": "",  
                "gender": "男",  
                "nickname": "test2",  
                "push_clientid": "",  
                "register_date": 1676890325757,  
                "register_ip": "210.196.131.171",  
                "role": [  
                    "storeManager",  
                    "admin"  
                ],  
                "score": 0,  
                "status": 0,  
                "wx_openid": ""  
            }  
        ],  
        "group_description": "群组简介3",  
        "group_icon": "",  
        "group_members": [  
            {  
                "_id": "6418170509e29881605a2c4f",  
                "avatar": "",  
                "comment": "",  
                "gender": "男",  
                "nickname": "test2",  
                "push_clientid": "",  
                "register_date": 1676890325757,  
                "register_ip": "210.196.131.171",  
                "role": [  
                    "storeManager",  
                    "admin"  
                ],  
                "score": 0,  
                "status": 0,  
                "wx_openid": ""  
            }  
        ],  
        "group_name": "群组名称3",  
        "prohibitionList": [  
        ]  
    },  
    {  
        "_id": "64181c4e28064a03b7a09e65",  
        "create_time": 1679301709648,  
        "group_admins": [  
            {  
                "_id": "63f350d50c801c3e624d9e94",  
                "avatar": "",  
                "comment": "",  
                "gender": "男",  
                "nickname": "是芦柑不是丑橘",  
                "push_clientid": "",  
                "register_date": 1676890325757,  
                "register_ip": "210.196.131.171",  
                "role": [  
                    "storeManager",  
                    "admin"  
                ],  
                "score": 0,  
                "status": 0,  
                "wx_openid": ""  
            },  
            {  
                "_id": "6418170509e29881605a2c4f",  
                "avatar": "",  
                "comment": "",  
                "gender": "男",  
                "nickname": "test2",  
                "push_clientid": "",  
                "register_date": 1676890325757,  
                "register_ip": "210.196.131.171",  
                "role": [  
                    "storeManager",  
                    "admin"  
                ],  
                "score": 0,  
                "status": 0,  
                "wx_openid": ""  
            }  
        ],  
        "group_description": "群组简介2",  
        "group_icon": "",  
        "group_members": [  
            {  
                "_id": "63f350d50c801c3e624d9e94",  
                "avatar": "",  
                "comment": "",  
                "gender": "男",  
                "nickname": "username",  
                "push_clientid": "xxx",  
                "register_date": 1676890325757,  
                "register_ip": "210.196.131.171",  
                "role": [  
                    "storeManager",  
                    "admin"  
                ],  
                "score": 0,  
                "status": 0,  
                "wx_openid": ""  
            },  
            {  
                "_id": "6418170509e29881605a2c4f",  
                "avatar": "",  
                "comment": "",  
                "gender": "男",  
                "nickname": "test2",  
                "push_clientid": "xxxx",  
                "register_date": 1676890325757,  
                "register_ip": "210.196.131.171",  
                "role": [  
                    "storeManager",  
                    "admin"  
                ],  
                "score": 0,  
                "status": 0,  
                "wx_openid": ""  
            }  
        ],  
        "group_name": "群组名称2",  
        "prohibitionList": [  
        ]  
    }  
]```  

实际结果:
    {  
        "_id": "641818baf5cf3a3e09971cd0",  
        "create_time": 1679300789398,  
        "group_admins": [  
        ],  
        "group_description": "群组简介3",  
        "group_icon": "https://mp-b351be1c-c14f-45b0-8b82-9be58b3d7a35.cdn.bspapp.com/cloudstorage/628e250e-cfe0-4c29-a63a-969c21824afd.png",  
        "group_members": [  
        ],  
        "group_name": "群组名称3",  
        "prohibitionList": [  
        ]  
    },  
    {  
        "_id": "64181c4e28064a03b7a09e65",  
        "create_time": 1679301709648,  
        "group_admins": [  
        ],  
        "group_description": "群组简介2",  
        "group_icon": "https://mp-b351be1c-c14f-45b0-8b82-9be58b3d7a35.cdn.bspapp.com/cloudstorage/628e250e-cfe0-4c29-a63a-969c21824afd.png",  
        "group_members": [  
        ],  
        "group_name": "群组名称2",  
        "prohibitionList": [  
        ]  
    }  
]

bug描述:

group表多个字段关联users表的_id字段后

旧联表查询写法 能够正常返回关联数据
db.collection("group,users").get()
新联表写法
const group = db.collection('group').getTemp() const user = db.collection('users').getTemp() db.collection(group,user).get()
关联字段的返回结果为空数组

2023-03-22 10:03 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

group_members这几个字段需要加上bsonType: "array"才会被作为数组处理

  • 2***@qq.com (作者)

    原来如此!谢谢

    2023-03-22 12:03

要回复问题请先登录注册