Read Properties
On this page
This page describes how to read and query specific property types, and properties that have special behaviors, with Atlas Device SDK.
For other information related to reading data from the database, refer to:
Read Objects: General information about read operations, including information on how to access, sort, and limit results.
Information about specific query APIs and supported operators:
RQL: C++, C#, Dart, Java, JavaScript, Kotlin, TypeScript
LINQ: C#
Type-Safe and NSPredicate Queries: Swift, Objective-C
Fluent Interface: Java, Kotlin (Java SDK)
Filter by Property Type
Query Collections (List, Set, Dictionary)
Query List Properties
Query Set Properties
Query Dictionary Properties
Query Geospatial Data
The SDK provides several shapes to simplify querying geospatial data. You can use the circle, polygon, and box shapes to set the boundaries for your geospatial data queries.
To query geospatial data:
Define a geospatial shape representing the bounds within which you want to query data.
Use the geospatial shape in a query with the relevant geospatial query operators.
Define Geospatial Shapes
Query with Geospatial Shapes
After you define a geospatial shape, you can use these shapes in a geospatial query.
Query a Mixed Property
A Generic (Mixed) Data Type property represents a polymorphic value that can hold any one of its supported data types at a particular moment. You can query a mixed property the same way you would any property.
Query Nested Collections of Mixed Data
A mixed data type can hold collections (a list or dictionary, but not a set) of mixed elements. You can use mixed collections to model unstructured or variable data. For more information, refer to Model Unstructured Data.
You can nest mixed collections up to 100 levels.
You can query mixed collection properties and register a listener for changes, as you would a normal collection.
You can find and update individual mixed collection elements
You cannot store sets or embedded objects in mixed collections.
For details about supported operators and list comparisons, refer to the Mixed Properties with Nested Data documentation.
Query a Custom Persistable Property
When you use type projection to map unsupported types to supported types, accessing those properties is often based on the persisted type.
Filter by Property Behaviors
Find an Object by Primary Key
Finding a specific object by its primary key is a common operation, which some of the SDK languages support through a dedicated method.
Tip
Device Sync Always Uses _id as Primary Key
If you use Atlas Device Sync, you can always query by the primary key
field _id
. This is because the Device Sync data model requires
objects have a primary key named _id
. For more information, refer to
Model Data with Device Sync.
Filter by Remapped Property Name
If your data model includes stored property names that you have mapped to different names, you can filter by both the mapped property name used in your code and the stored property name that's persisted in the database.
Filter a Full-Text Search Property
If your data model includes a Full-Text Search (FTS)
index property, you can filter by the property using the TEXT
predicate.
Words in the query are converted to tokens by a tokenizer using the following
rules:
Tokens can only consist of characters from ASCII and the Latin-1 supplement (western languages). All other characters are considered whitespace.
Words split by a hyphen (
-
) are split into two tokens. For example,full-text
splits intofull
andtext
.Tokens are diacritics- and case-insensitive.
You can search for an entire word or phrase, or limit your results with the following characters:
Exclude results for a word by placing the
-
character in front of the word. For example,fiction -science
would include all search results forfiction
and exclude those that include the wordscience
.Specify prefixes by placing the
*
character at the end of a word. For example,fict*
would include all search results forfiction
andfictitious
. The SDK does not currently support suffix searches.
The SDK returns a Boolean match for the specified query, instead of a relevance-based match.
Filter Relationships
Query a To-One Relationship
A to-one relationship property maps to a single instance of another object type. You can filter by the relationship property using dot notation, the same way you would a nested object.
The SDK requires to-one relationships to be optional. Your code should handle the possible nil or null value.
Query a To-Many Relationship
To-many relationships properties are collections to another object type:
You can filter by and iterate through the relationship property the same way you would any other collection property.
Query an Inverse Relationship
An inverse relationship links an object back to any other objects that refer to it in a defined to-one or to-many relationship. Relationship definitions are unidirectional, so you must explicitly define a property in the object's model as an inverse relationship.
When you follow an inverse relationship, the result may include zero or more objects. You must access the collection to work with an originating object.