【发布时间】:2020-05-30 11:20:35
【问题描述】:
我正在尝试在我的应用程序中创建一个功能,允许用户选择两种药物,并在第三个屏幕中获取这两种药物是否有交互的结果。
为此,我有一个数据库,其中所选择的药物在交互数据库中传递一个“ATC”编号,称为 GRP1D 或 GRP2D。传递的两个 ATC 编号应与数据库中的 GRPD 编号进行比较,以便返回交互,如果没有,则应返回“无交互”。理想情况下,我会使用多个 where 子句和一个 OR 子句来使传递的 ATC 编号的顺序无关紧要。
我已经尝试了很多东西,但最后我什至不确定这是否可以通过 Firestore 实现。这里是数据库的相关部分
下面是我希望它工作的代码,显然它不是因为在 firestore 中似乎没有 OR 甚至多个 where 子句。任何想法如何解决?提前非常感谢!
render() {
console.log(this.state.atc1);
console.log(this.state.atc2);
var atc1 = this.state.atc1
var atc2 = this.state.atc2
var interactiondescription
dbh.collection('IX')
.where('GRP1D', '==', atc1)
.where('GRP2D', '==', atc2)
or
.where('GRP1D', '==', atc2)
.where('GRP2D', '==', atc1)
.get()
.then(querySnapshot => {
querySnapshot.forEach(doc => {
interactiondescription = doc.data().MEASD
console.log('this', interactiondesctription)
})
});
//console.log('Desc:', this.interactiondescription)
【问题讨论】:
标签: javascript react-native google-cloud-firestore