Generate many conditions "equalTo" on "fly"
See original GitHub issueRealm 4.1.
public static Merchant getMerchant(int merchantId) {
Realm realm = Realm.getDefaultInstance();
try {
return realm.where(Merchant.class)
.equalTo(Merchant.ID, merchantId)
.findFirst();
} finally {
realm.close();
}
}
OK. It’s work fine. But suppose I has map of fields to filter. And I want to iterate all fileds from map “fieldsAndValues” and on “fly” generate many conditions “equalTo” equals to map’s size. Something like this (psedo code):
public static Merchant getMerchant(Map<String, String> fieldsAndValues) {
Realm realm = Realm.getDefaultInstance();
try {
return realm.where(Merchant.class)
.equalTo("fieldName_1", fieldValue_1)
.equalTo("fieldName_2", fieldValue_2)
...
.equalTo("fieldName_N", fieldValue_N)
.findFirst();
} finally {
realm.close();
}
}
Is it possible?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
PHP If Statement with Multiple Conditions - Stack Overflow
I want echo "true" if $var is equal to any of the following values abc , def , hij , klm , or...
Read more >Using conditions for personalization - Help Center - WordFly
Conditions give you a powerful way to send customized content to each subscriber. Instead of creating a new email design with different content ......
Read more >How your flight emits as much CO2 as many people do in a year
How your flight emits as much CO2 as many people do in a year. Even short-haul flights produce huge amounts of CO2, figures...
Read more >Power Automate Trigger Conditions made EASY
Within this blog we'll look at how we can quickly and easily create our trigger conditions so that we know they are working....
Read more >If Statements - Happy Coding
You can think about the code like this: “If the score is greater than or equal to 90, then display the 'Congratulations! '...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d probably throw an IllegalArgumentException instead of
return null
there, but yeah 👍It works if there is at least 1 more open Realm instance on the thread.
Something like this?