len168com
len168com
  • 发布:2022-08-10 11:32
  • 更新:2022-08-11 16:42
  • 阅读:318

【报Bug】联表查询uni-id-users无法返回指定字段

分类:uniCloud

产品分类: uniCloud/App

示例代码:

云函数内查询

let dbCmd = this.ctx.dbJQL.command  
let comment = this.ctx.dbJQL.collection("kcc-user-dynamic-comment")  
            .field('user_id,dynamic_id,content,status,create_date')  
            .orderBy('create_date', "desc")  
            .getTemp();  
let user = this.ctx.dbJQL.collection("uni-id-users")  
            .field('_id,nickname,avatar,gender')  
            .getTemp();  
await this.ctx.dbJQL.collection(comment, user)  
            .get()  
            .then(res => {  
                result = {code: 1, message: "success", data: res.data};  
            }).catch(err => {  
                result = {code: 0, message: err.message, data: []};  
            });  
        return result

操作步骤:

云函数内查询

let dbCmd = this.ctx.dbJQL.command  
let comment = this.ctx.dbJQL.collection("kcc-user-dynamic-comment")  
            .field('user_id,dynamic_id,content,status,create_date')  
            .orderBy('create_date', "desc")  
            .getTemp();  
let user = this.ctx.dbJQL.collection("uni-id-users")  
            .field('_id,nickname,avatar,gender')  
            .getTemp();  
await this.ctx.dbJQL.collection(comment, user)  
            .get()  
            .then(res => {  
                result = {code: 1, message: "success", data: res.data};  
            }).catch(err => {  
                result = {code: 0, message: err.message, data: []};  
            });  
        return result

预期结果:
{  
    "code": 1,  
    "message": "success",  
    "data": [{  
        "_id": "62f267231341c70001c9d757",  
        "dynamic_id": "62f25775302d9f0001e1dc2f",  
        "content": "123",  
        "user_id": [{  
            "_id": "62d3b2b31341c700014666be",  
            "nickname": "老死不相往来",  
            "avatar": "",  
            "gender": 0  
        }],  
        "status": 1,  
        "create_date": 1660053281780  
    }, {  
        "_id": "62f265d3f6d1400001791ef9",  
        "dynamic_id": "62f25775302d9f0001e1dc2f",  
        "content": "123",  
        "user_id": [{  
            "_id": "62d3b2b31341c700014666be",  
            "nickname": "老死不相往来",  
            "avatar": "",  
            "gender": 0  
        }],  
        "status": 1,  
        "create_date": 1660052945855  
    }]  
}  

实际结果:
{  
    "code": 1,  
    "message": "success",  
    "data": [{  
        "_id": "62f267231341c70001c9d757",  
        "dynamic_id": "62f25775302d9f0001e1dc2f",  
        "content": "123",  
        "user_id": [{  
            "_id": "62d3b2b31341c700014666be",  
            "nickname": "老死不相往来"  
        }],  
        "status": 1,  
        "create_date": 1660053281780  
    }, {  
        "_id": "62f265d3f6d1400001791ef9",  
        "dynamic_id": "62f25775302d9f0001e1dc2f",  
        "content": "123",  
        "user_id": [{  
            "_id": "62d3b2b31341c700014666be",  
            "nickname": "老死不相往来"  
        }],  
        "status": 1,  
        "create_date": 1660052945855  
    }]  
}

bug描述:

云函数内查询副表uni-id-users联表查询时无法返回指定的字段

let dbCmd = this.ctx.dbJQL.command  
let comment = this.ctx.dbJQL.collection("kcc-user-dynamic-comment")  
            .field('user_id,dynamic_id,content,status,create_date')  
            .orderBy('create_date', "desc")  
            .getTemp();  
let user = this.ctx.dbJQL.collection("uni-id-users")  
            .field('_id,nickname,avatar,gender')  
            .getTemp();  
await this.ctx.dbJQL.collection(comment, user)  
            .get()  
            .then(res => {  
                result = {code: 1, message: "success", data: res.data};  
            }).catch(err => {  
                result = {code: 0, message: err.message, data: []};  
            });  
        return result
2022-08-10 11:32 负责人:无 分享
已邀请:
len168com

len168com (作者)

官方的人死那去了? avatar不返回你就算了 gender这个字段都不给返回 要返回什么字段我们自己定,你们写死了算什么意思

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