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