Workaround: How to dynamically query a list property


#1

Hey there,

can someone show me how to query an array of strings with realm in react-native?

It is really important for me. I would donate little money for your efforts.

assume i have an array like the following:

const preferences = ["automatic","suv","blue",eco]

What I want is to get realm results where ALL strings in the attribute “specifications” of Cars is in “preferences”.

E.g.: If an instance of Cars.specifications contains [“automatic”,“suv”] a result should be returned.

But if an instance of Cars.specifications contained ["automatic,“suv”,“green”] this instance shouldn’t be returned.

The length of preferences can vary.

schema of Cars:

schema = {
    name: 'Cars',
    primaryKey: "name",
    properties: {
        name: 'string',
        category: "string",
        image: "string",
        specifications: "string[]"
    },

Thank you very much.

UPDATE: It seems like that this feature is not supported yet, but maybe a Workaround - GitHub exists with using objets. But I couldn’t figure out how it should work.