亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

火店難題!將 .where() 用于數組和字符串

火店難題!將 .where() 用于數組和字符串

慕容森 2021-06-07 10:25:02
我正在嘗試使用 firestore 的 .where() 功能來檢測某個字符串是否在數據庫中的數組中。我嘗試通過添加括號和其他東西來表示數組的一部分來操縱函數的第一個參數,但無濟于事。//in this section I am getting the "yourLikes" integer (unrelated to the problem)var liks = [];var tempLiks = []db.collection("users").where("uid", "==", uid).get().then(function(querySnapshot) {    querySnapshot.forEach(function(doc) {      tempLiks = doc.data().yourLikes;      // I am using a setTimeout() function to allow firebase to       // process the previous query and give me the doc.data().yourLikes for tempLiks      setTimeout(function(){      //Right here, the "usersLiked" data is an array, with a bunch of different values.       // I am trying to see if one of those values is doc.data().uid from my previous query. (I think) this is the problem.       db.collection("memeInfo").where("usersLiked", "==", doc.data().uid)        .get()        .then(function(querySnapshot) {            querySnapshot.forEach(function(doc) {              for (var i = 0; i < tempLiks.length; i++) {                liks.push([tempLiks[i],doc.data().likes])                console.log(liks)              }            })          })      },500)如果有人有一個解決方案來查詢單個值是否在數組中而不永遠使用 for 循環(我可能在 usersLiked 數組中有數千個值),那將不勝感激。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 150 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號