Angular Firestore |如何让数组不包含 [英] Angular Firestore | how to get array not contain

查看:19
本文介绍了Angular Firestore |如何让数组不包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用 Angular Firestore,但我在编写一个查询时遇到了问题,该查询将返回我需要的所有对象

I'm using Angular Firestore in my app, and I'm having a problem to write a query that will return all of the objects I'm needed

在下面的例子中,我得到了所有在eat_by数组中获得该用户ID的水果

In the following example, I get all the fruits that got that user id in their eat_by array

this.asf.collection('fruits', ref => ref.where('eat_by', 'array-contains', userId)).valueChanges();

而且它的工作很棒

但我遇到的问题是做相反的事情;我试图让没有那个 userId 的水果被数组吃掉.就像 mongo 中的 $nin.

But the problem I'm having is doing the opposite thing; I'm trying to get the fruits that don't have that userId in there eat by the array. Like $nin in mongo.

我需要字段值不在指定的数组运算符中

I need that the field value is not in the specified array operator

你之前处理过那件事吗?

did you handle with that thing before ?

你是怎么解决的?

有什么好的解决方法吗?

there is any good workaround ?

谢谢

推荐答案

firebaser here

目前没有数组不包含"操作是 Cloud Firestore.

There is no "array does not contain" operation is Cloud Firestore at the moment.

我强烈建议阅读 Doug 的回答在这里,因为它解释了为什么不支持此操作.不幸的是,那里提出的解决方法不适用于数组不包含"操作.

I highly recommend reading Doug's answer here, as it explains why this operation is not supported. Unfortunately the workaround proposed there, won't work for "array does not contain" operations.

这篇关于Angular Firestore |如何让数组不包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆