Removing Soup Elements

Traditionally, SmartStore methods let you remove soup elements by specifying an array of element IDs. To do so, you usually run a preliminary query to retrieve the candidate IDs, then call the method that performs the deletion. In Mobile SDK 4.2, SmartStore ups the game by adding a query option to its element deletion methods. With this option, you provide only a query, and SmartStore deletes all elements that satisfy that query. This approach delivers a performance boost because both the query and the deletion operation occur in a single call.

In hybrid apps, you use the third parameter to pass either an ID array or a SmartStore query spec.

In addition to success and error callbacks, this function takes the following arguments:

Parameter NameArgument Description
isGlobalStore(Optional) Boolean that indicates whether this operation occurs in a global or user-based SmartStore database. Defaults to false.
storeConfig(Optional) StoreConfig object that specifies a store name and whether the store is global or user-based.
soupNameString. Pass in the name of the soup.
entryIdsOrQuerySpecArray or QuerySpec object. Pass in the name of the soup.

Android native methods for removing entries give you the option of either handling the transaction yourself, or letting the method handle the transaction transparently. If you set the handleTx argument to false, you’re responsible for starting the transaction before the call and ending it afterwards. If you use the overload that doesn’t include handleTx, or if you set handleTx to false, Mobile SDK handles the transaction for you.

To remove entries by ID array in Android native apps, call either of the following methods:

To remove entries by query in Android native apps, call either of the following methods:

In this example, the soup "MySoup" has a string field called "key". To delete all entries that have a key starting with "abc", call the method like this:

To remove entries by ID array in iOS native apps, call one of these methods:

Example:

To remove entries by query in iOS native apps, call one of these methods:

In this example, the soup "MySoup" has a string field called "key". To delete all entries that have a key starting with "abc", call the method like this:

Example: