8***@qq.com
8***@qq.com
  • 发布:2022-11-10 16:21
  • 更新:2022-11-10 17:59
  • 阅读:296

unicloud for循环查询,只有第一条有数据,其它的是空数据,但单个查询都有数据。为什么这样?

分类:uniCloud

unicloud for循环查询,
只有第一条有数据,其它的是空数据,
但单个查询都有数据。为什么这样?
有没有大佬给我解决一下。

async getpeopledata(){  
                let that = this;  
                let db = uniCloud.database();  
                    let res = await db.collection("people")  
                .orderBy('_id','desc')  
                .skip(that.skipnum).limit(that.limitnum)  
                .get();  

                that.peopledata = res.result.data;  

                for(let i=0;i<that.peopledata.length;i++){  
                    let rres = await that.getclientdata(that.peopledata[i]._id);  
                    console.log(rres.result.data);  
                }  
                this.$emit("isok", true)  
            },  
getclientdata(id){  
                console.log(id);  
                let db = uniCloud.database();  
                let p = new Promise((result,reject)=>{  
                    db.collection('client')  
                    .where(`otherpeople=='${id}' || mainpeople=='${id}'`)  
                    .field("_id,clientname")  
                    .get()  
                    .then(res=>{  
                        result(res)  
                    })  
                    .catch(err=>{  
                        reject(err)  
                    })  
                });  
                return p;  
            },  

查询结果
16:06:34.245 63679156a89937000128dd37 at pages/msg/tab/keeptab.vue:38
16:06:34.389 [Object] [{"_id":"63638954d4fe2f0001958a41","clientname":"测试"}] at pages/msg/tab/keeptab.vue:30 at pages/msg/tab/keeptab.vue:30
16:06:34.392 63675a29642bcb000145336c at pages/msg/tab/keeptab.vue:38
16:06:34.574 [Object] [] at pages/msg/tab/keeptab.vue:30 at pages/msg/tab/keeptab.vue:30
16:06:34.580 63638954642bcb0001cd2f86 at pages/msg/tab/keeptab.vue:38
16:06:34.861 [Object] [] at pages/msg/tab/keeptab.vue:30 at pages/msg/tab/keeptab.vue:30

2022-11-10 16:21 负责人:无 分享
已邀请:
8***@qq.com

8***@qq.com (作者)

dbCmd.or({
otherpeople:id
},{
mainpeopleid:id
})

应该这样设置查询条件才能查到,搞定了。真是郁闷!

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