firebase - Cloud Functions 中使用的 Firestore where 子句中是否有“!=”运算符?
问题描述
我想从 GET 请求中排除一些文档,所以我编写了以下代码(注意行users = users.where(admin.firestore.FieldPath.documentId(), '!=', k);
):
let users = admin_firestore.collection('users');
const likes = admin_firestore.collection('likes_of_users_posts');
likes.get().then(function(likes_docs) {
const map_users_id_with_number_of_likes = [];
likes_docs.forEach(like_doc => {
if(!(like_doc.data().post_owner in map_users_id_with_number_of_likes)) {
map_users_id_with_number_of_likes[like_doc.data().post_owner] = 0;
}
map_users_id_with_number_of_likes[like_doc.data().post_owner] += 1;
});
Object.keys(map_users_id_with_number_of_likes).forEach((k) => {
users = users.where(admin.firestore.FieldPath.documentId(), '!=', k);
});
它是我的 Google Cloud Functions 功能的一部分。
当我在 Android 应用程序中执行此 Cloud Function 函数时,我可以在日志中看到以下错误:
错误:参数“opStr”的值无效。可接受的值为:<、<=、==、>、>=、数组包含
但是我真的需要写一些相当于:“不同于 X 并且不同于 Y 和......”。所以.where(admin.firestore.FieldPath.documentId(), '!=', k)
像我一样链接。
解决方案
推荐阅读
- python - Python - 如果列表中的总字符数超过 X,则将列表拆分为多个列表
- php - 试图从 php 中的会话中获取用户名
- mongodb - 如何使用正则表达式查询 MongoDB?
- javascript - Rails 使用 remote: true 来控制弹出窗口
- spring - 从 Webflux 的 GET 操作内部对外部休息服务进行 Get 和 PUT 调用
- angular - Angular 2- 生成 CSV 文件并将其下载为 Zip 文件
- sql-server - 在 SQL Server 中插入时根据 ID 计算的列值
- javascript - 如何在 VueJS 中将组件呈现为数据属性
- reactjs - 在应用程序初始化 React Native、Redux-Persist 时从持久存储中检索令牌
- java - 鳄梨酱获得分享链接连接的密钥