Using Arrays in Index Paths
Index paths can contain arrays, but certain rules apply.
Before Mobile SDK 4.1, index paths supported only maps—in other words, dictionaries or associative arrays. For example, in a path such as a.b.c, SmartStore required both b and c to be maps. Otherwise, when evaluating the path, SmartStore returned nothing.
In Mobile SDK 4.1 and later,
index paths can contain arrays and maps. In the a.b.c
example, if the value of b is an array, SmartStore expects the array to
contain maps that define c. SmartStore then returns an array
containing values of c keys found in the b array’s maps.
Example
The following table shows various examples of a.b.c paths and the values returned by a SmartStore query.
| Description | Example soup element | Value for path a.b.c |
|---|---|---|
| No arrays |
|
1 |
| c points to an array (internal node). |
|
|
| b points to an array of maps. Some maps contain the c key. Other maps are ignored. |
|
|
| a points to an array of maps. In some maps, b points to a map containing a key. In other maps, b points to an array of maps. Only values from c keys are returned. |
|
|