firebase中的AND-OR条件查询Javascript

时间:2017-07-25 13:09:33

标签: javascript firebase firebase-realtime-database

无法在谷歌文档上找到任何答案,所以我不得不问这个。

如何在其中点击带有OR条件的查询到firebase服务器。

基本上,我想检查数据库中是否已存在特定聊天会话。聊天可以有两种类型的ID(steveandjacob或jacobandsteve),如何检查数据库中是否存在其中一种?

这是我写的一些代码。

var currentUserID = localstorage.getItem('currentUserID');
    var chatid = currentUserID+''+anotherUserID;
    var chatid2 = anotherUserID+''+currentUserID;
    var ref = firebase.database().ref('messages/conv').orderByChild('chatid').equalTo(chatid);
    ref.on('value', function(snapshot) {
       if (snapshot.exists())
          alert ("exist");
       else
          alert ("not exist");
    });

怎么做?

0 个答案:

没有答案