在 ionic 和 loopback 中对对象使用 where 过滤器
using where filter with an object in ionic and loopback
我的数据库是这样的
“status”: “todo”,
“author”: {
“username”: “henro92”,
“email”: "henry.unah@rocketmail.com",
“id”: “5a8aeb6b687d1b041471e4cc”
},
“source”: {
“username”: “h82”,
“email”: "henry.unah@gmail.com",
“id”: “5a71cb7637b4492704006e47”,
“firstname”: “Henry”,
“lastname”: “Jordan”,
“sex”: " Male ",
“dateOfBirth”: “2018-01-31”
}
我想通过像这样的对象的来源查找数据,但它不起作用
this.questionnaireresponseapi.findOne({
where: {
source:
this.loopbackauth.getCurrentUserData().user
}
})
当我尝试使用字符串形式的状态时,它起作用了
this.questionnaireresponseapi.findOne({
where: {
source: this.loopbackauth.getCurrentUserData().user
}
})
知道如何解决这个问题吗?
我使用 source.id 解决了这个问题
this.questionnaireresponseapi.findOne({其中: {'source.id': this.loopbackauth.getCurrentUserId()}}).subscribe((数据)=>{
this.thequestionnaireResponse = 数据;
}
我的数据库是这样的
“status”: “todo”,
“author”: {
“username”: “henro92”,
“email”: "henry.unah@rocketmail.com",
“id”: “5a8aeb6b687d1b041471e4cc”
},
“source”: {
“username”: “h82”,
“email”: "henry.unah@gmail.com",
“id”: “5a71cb7637b4492704006e47”,
“firstname”: “Henry”,
“lastname”: “Jordan”,
“sex”: " Male ",
“dateOfBirth”: “2018-01-31”
}
我想通过像这样的对象的来源查找数据,但它不起作用
this.questionnaireresponseapi.findOne({
where: {
source:
this.loopbackauth.getCurrentUserData().user
}
})
当我尝试使用字符串形式的状态时,它起作用了
this.questionnaireresponseapi.findOne({
where: {
source: this.loopbackauth.getCurrentUserData().user
}
})
知道如何解决这个问题吗?
我使用 source.id 解决了这个问题 this.questionnaireresponseapi.findOne({其中: {'source.id': this.loopbackauth.getCurrentUserId()}}).subscribe((数据)=>{ this.thequestionnaireResponse = 数据;
}