我正在尝试使用 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 数组中有数千个值),那将不胜感激。
添加回答
举报
0/150
提交
取消