Docs Menu
Docs Home
/ /
Atlas Device SDKs
/
/

Create Specific Property Types

On this page

  • Create Special Properties
  • Create a Generic (Mixed) Property
  • Create a Counter Property
  • Create a Timestamp Property
  • Create an Object ID Property
  • Create a UUID Property
  • Create Collection Properties
  • Create List Properties
  • Create Set Properties
  • Create Dictionary Properties
  • Create Relationship Properties
  • Create a To-One Relationship
  • Create a To-Many Relationship
  • Create an Inverse Relationship

This page describes how to create specific property types, including:

  • Special SDK-specific types, such as counters or mixed data types

  • Collection property types, such as lists, sets, and maps

  • Relationship property types, including to-one, to-many, and inverse relationships

To learn more about how to define these property types in the object model, refer to Define an SDK Object Model.

For information about how to create specific types of objects, refer to Create Specific Object Types.

For information about write transactions and the methods you can use to create objects, refer to Create Objects.

Depending on how you define your object type, you might have properties that are special SDK-specific types. These may be custom data types, or familiar language types that have specific requirements or limitations when used with Atlas Device SDK.

The SDK provides a generic mixed property type that could contain a number of property types. It's the closest analog to a polymorphic data type that the SDK provides.

For a list of the value types that a mixed property can hold, refer to Generic (Mixed) Data Type.

Some of the SDKs provide a special property type that you can use as a logical counter.

The SDK provides the following collection type properties:

  • List

  • Set

  • Map

Collections are mutable within a write transaction.

Tip

Listen for Changes to a Created Collection

After you create a collection, you can register a notification handler to listen for changes. For more information, refer to Register a Collection Change Listener.

The SDK's list data type is a container that holds a collection of primitive values or objects. These values may be of any supported type except another collection.

The SDK uses the List container type to define to-many relationships. A to-many relationship means that an object is related in a specific way to multiple objects.

For a list of the value types that a list property can hold, refer to Define a List Property.

Like their native counterparts, the SDK's set data type stores unique values. These values may be a Realm object or one of the supported data types. It cannot be another collection, an embedded object, or an asymmetric object.

The SDK uses the Set container type to define to-many relationships. A to-many relationship means that an object is related in a specific way to multiple objects.

For a list of the value types that a set property can hold, refer to Define a Set Property.

The SDK supports a dictionary (map) property type. Dictionary keys must be strings, but values can be any of the supported value types. For a list of the value types that a dictionary property can hold, refer to Define a Dictionary Property.

When you have a property whose type references another SDK object, this creates a relationship between the objects. This can be a to-one, to-many, or inverse relationship. For more information about relationships, refer to Model Relationships.

To create a new object instance with a to-one relationship property, instantiate both objects and pass the referenced object to the relationship property.

You can optionally create an inverse relationship to refer to the main object from the related object. For more information, refer to the Create an Inverse Relationship section on this page.

To create a new object instance with a to-many relationship property, instantiate all objects and pass any referenced objects to the relationship collection property.

You may use a List or a Set to represent a to-many relationship, depending on whether you require the values to be unique, or whether you want to use any of the special collection type methods.

You can optionally create an inverse relationship to refer to the main object from the related object. For more information, refer to the Create an Inverse Relationship section on this page.

To create a new object instance with an inverse relationship property, instantiate the parent object and pass any referenced child objects to the inverse relationship property.

After you create an object that has an inverse relationship, you can access the inverse relationship property to get the child objects. However, you cannot directly modify the backlink itself. For more information, refer to Update Inverse Relationships.

← 
 →