本文介绍了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此处

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 |如何获取数组不包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 03:50