I'm trying to determine if an array of records exist in the Smartstore based on their Name.

Ex. I have 'John', 'Bill', 'Frank' in the Smartstore and want to know if 'Bill' and 'Al' exist in one query.

Basically the equivlent of IN in SOQL. I don't see any way to do that based on the smartstore query options, even using Smart SQL here: https://developer.salesforce.com/docs/atlas.en-us.mobile_sdk.meta/mobile_sdk/offline_smart_sql.htm?language=en

Based on that link it looks like you currently can't include variables in the where clause.

My current plan is to just do the query everything option and iterate though it looking for my records, but it doesn't seem very efficient.

Has anyone accomplished this or something similar?


You can query the soup using the following approach for a range. I use it all the time and it works well

buildRangeQuerySpec = function(path, beginKey, endKey, order, pageSize)

This QuerySpec allows you to specify a range of values with the beginKey and endKey parameters. For instance, if you wanted to query all Names between “Adams” and “Zaphod”, you would want to use this QuerySpec.

buildLikeQuerySpec = function(path, likeKey, order, pageSize)

Similarly, to do a 'like', you can use

buildLikeQuerySpec = function(path, likeKey, order, pageSize)

The query is similar to the LIKE clause, and allows you to search for a substring within string indexes. This is useful if a user is entering a search string because you can return, for instance, all names starting with “Arthur.”

| improve this answer | |
  • This doesn't really address the example I provided but it seems that the functionality I'm looking for just doesn't exist yet. – Phil B Aug 8 '14 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.