I’m working on a React Native app, using Realm. I need to find all the items in a table, where a certain “name” property contains a constant string, or the other way around. Normally, I would do something like this:
However, I need to return the results where model.name contains ‘myString’ OR ‘myString’ contains model.name. I tried “‘myString’ CONTAINS[c] name” but it doesn’t work. Is there a way to accomplish what I need to do using only Realm queries?
I have a list of objects with string names, and I need to find the items that match a specific substring. The list includes items like Door, Window, Car. But sometimes it can include things like Door 2, Car 3.
So far, I can input the string “Window”, and it will match, for example, “Window” and “Window 2”. However, if I input “Window 1”, it won’t match “Window”, and for my particular use case, this is necessary. I could query all the items, and then compare them using Javascript, but this is slow. I was wondering if the Realm query language had support for something like this.
Window 1 would not match Window unless you are attempting to find all matches that start the same (the beginning of the string), OR you toss out anything not relevant, like the ‘1’ and then do a search
In either case though, it would still be a partial string search.
I don’t believe there would be any way to match Window 1 to Window in any language - perhaps you can share a snippet of code that would perform the match? Then we can see more specifically what that does and try to come up with a Realm based solution.