司马琦昂
司马琦昂
  • 发布:2024-11-25 17:28
  • 更新:2024-11-25 17:28
  • 阅读:11

【报Bug】uniCloud联合查询时没有返回预期结果

分类:uniCloud

产品分类: uniCloud/支付宝小程序云

示例代码:

demo-classify.schema.json

{  
    "bsonType": "object",  
    "required": [],  
    "permission": {  
        "read": true,  
        "create": true,  
        "update": true,  
        "delete": true  
    },  
    "properties": {  
        "_id": {  
            "description": "ID,系统自动生成"  
        },  
        "name": {  
            "title": "分类明细",  
            "bsonType": "string"  
        }  
    }  
}

demo-classify.init_data.json

[  
    {  
        "name": "可爱萌宠"  
    },  
    {  
        "name": "明细美女"  
    }  
]

demo-wallpaper.schema.json

{  
    "bsonType": "object",  
    "required": [],  
    "permission": {  
        "read": true,  
        "create": true,  
        "update": true,  
        "delete": true  
    },  
    "properties": {  
        "_id": {  
            "description": "ID,系统自动生成"  
        },  
        "picurl": {  
            "title": "壁纸链接地址",  
            "bsonType": "string"  
        },  
        "description": {  
            "title": "壁纸描述",  
            "bsonType": "string"  
        },  
        "classid": {  
            "title": "分类ID",  
            "bsonType": "string",  
            "foreignKey": "demo-classify._id"  
        }  
    }  
}

demo-wallpaper.init_data.json

[  
    {  
        "picurl": "https://cdn.qingnian8.com/public/xxmBizhi/20240726/1721962301068_0_small.webp",  
        "description": "动漫女孩绘画。图源:wallhaven.cc@HiguchiMadokaS",  
        "classid": "67440ffcded73e34897288a0"  
    },  
    {  
        "picurl": "https://cdn.qingnian8.com/public/xxmBizhi/20241024/1729750258702_2_small.webp",  
        "description": "杨幂绝美活动造型释出,亮闪开衩礼服尽显玲珑身材,女王霸气十足。图源:微博@杨幂工作室",  
        "classid": "67440ffcded73e34897288a1"  
    },  
    {  
        "picurl": "https://cdn.qingnian8.com/public/xxmBizhi/20240318/1710770064235_3_small.webp",  
        "description": "永远的七龙珠,童年的回忆,神龙显现。图源:微博@每阅壁纸",  
        "classid": "67440ffcded73e34897288a0"  
    }  
]

操作步骤:

JQL查询

db.collection("demo-wallpaper", "demo-classify").get();

预期结果:
[  
    {  
        "_id": "67443fbdc0bd20b1cfe261a8",  
        "classid": [  
            {  
                "_id": "67440ffcded73e34897288a0",  
                "name": "可爱萌宠"  
            }  
        ],  
        "description": "动漫女孩绘画。图源:wallhaven.cc@HiguchiMadokaS",  
        "picurl": "https://cdn.qingnian8.com/public/xxmBizhi/20240726/1721962301068_0_small.webp"  
    },  
    {  
        "_id": "67443fbdc0bd20b1cfe261a9",  
        "classid": [  
            {  
                "_id": "67440ffcded73e34897288a1",  
                "name": "明星美女"  
            }  
        ],  
        "description": "杨幂绝美活动造型释出,亮闪开衩礼服尽显玲珑身材,女王霸气十足。图源:微博@杨幂工作室",  
        "picurl": "https://cdn.qingnian8.com/public/xxmBizhi/20241024/1729750258702_2_small.webp"  
    },  
    {  
        "_id": "67443fbdc0bd20b1cfe261aa",  
        "classid": [  
            {  
                "_id": "67440ffcded73e34897288a0",  
                "name": "可爱萌宠"  
            }  
        ],  
        "description": "永远的七龙珠,童年的回忆,神龙显现。图源:微博@每阅壁纸",  
        "picurl": "https://cdn.qingnian8.com/public/xxmBizhi/20240318/1710770064235_3_small.webp"  
    }  
]

实际结果:
[  
    {  
        "_id": "67443fbdc0bd20b1cfe261a8",  
        "classid": [  
            {  
                "_id": "67440ffcded73e34897288a0",  
                "name": "可爱萌宠"  
            },  
            {  
                "_id": "67440ffcded73e34897288a1",  
                "name": "明星美女"  
            },  
            {  
                "_id": "674440ff841b9edfc93e5e67",  
                "name": "分类测试2"  
            }  
        ],  
        "description": "动漫女孩绘画。图源:wallhaven.cc@HiguchiMadokaS",  
        "picurl": "https://cdn.qingnian8.com/public/xxmBizhi/20240726/1721962301068_0_small.webp"  
    },  
    {  
        "_id": "67443fbdc0bd20b1cfe261a9",  
        "classid": [  
            {  
                "_id": "67440ffcded73e34897288a0",  
                "name": "可爱萌宠"  
            },  
            {  
                "_id": "67440ffcded73e34897288a1",  
                "name": "明星美女"  
            },  
            {  
                "_id": "674440ff841b9edfc93e5e67",  
                "name": "分类测试2"  
            }  
        ],  
        "description": "杨幂绝美活动造型释出,亮闪开衩礼服尽显玲珑身材,女王霸气十足。图源:微博@杨幂工作室",  
        "picurl": "https://cdn.qingnian8.com/public/xxmBizhi/20241024/1729750258702_2_small.webp"  
    },  
    {  
        "_id": "67443fbdc0bd20b1cfe261aa",  
        "classid": [  
            {  
                "_id": "67440ffcded73e34897288a0",  
                "name": "可爱萌宠"  
            },  
            {  
                "_id": "67440ffcded73e34897288a1",  
                "name": "明星美女"  
            },  
            {  
                "_id": "674440ff841b9edfc93e5e67",  
                "name": "分类测试2"  
            }  
        ],  
        "description": "永远的七龙珠,童年的回忆,神龙显现。图源:微博@每阅壁纸",  
        "picurl": "https://cdn.qingnian8.com/public/xxmBizhi/20240318/1710770064235_3_small.webp"  
    }  
]

bug描述:

在schema文件中,对字段指定外键foreignKey,进行关联查询。查询出关联表的所有数据,并不是关联字段值对应的数据。

2024-11-25 17:28 负责人:无 分享
已邀请:

要回复问题请先登录注册