领域中的字符串查询列表

时间:2021-04-29 00:58:38

I am working with Realm Swift and I am running into an issue where I need to write a query that filters Realm objects by both a boolean property and a List on a Realm object.

我正在使用Realm Swift,我遇到了一个问题,我需要编写一个查询,通过布尔属性和Realm对象上的List来过滤Realm对象。

The Realm objects I would like to filter have a List value and it contains an array of strings. The values in this List will only ever be one of the following possibilities: "US", "CA", or "US" and "CA".

我想要过滤的Realm对象有一个List值,它包含一个字符串数组。此列表中的值只能是以下可能之一:“US”,“CA”或“US”和“CA”。

How might I go about writing an appropriate predicate to filter by both a boolean and one of the values contained in the List property? So far I have tried this type of query with no success:

我如何编写一个适当的谓词来过滤布尔值和List属性中包含的值之一?到目前为止,我已经尝试过这种类型的查询但没有成功:

category.templates.filter("testMode = false AND countries CONTAINS 'US')

1 个解决方案

#1


0  

UPDATE: After doing some more digging around I found that this solution actually solved what I was attempting to do with Realm: Swift Realm filter List property using an Array

更新:在做了一些挖掘之后,我发现这个解决方案实际上解决了我试图用Realm做的事情:使用数组的Swift Realm过滤器List属性

#1


0  

UPDATE: After doing some more digging around I found that this solution actually solved what I was attempting to do with Realm: Swift Realm filter List property using an Array

更新:在做了一些挖掘之后,我发现这个解决方案实际上解决了我试图用Realm做的事情:使用数组的Swift Realm过滤器List属性