Docs Menu
Docs Home
/ /
Atlas Device SDKs
/
/

Create Specific Object Types

On this page

  • Create Specific SDK Object Types
  • Create a Realm Object
  • Create an Embedded Object
  • Create an Asymmetric Object
  • Create a Geospatial Data Object

This page describes how to create specific types of objects using Atlas Device SDK. To learn more about object models and how to define them, refer to Define an SDK Object Model.

You can create objects whose object type is managed by the database instance. For more information, refer to Configure & Open a Database File or Configure & Open a Synced Database.

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

For information about creating specific property types, including special types, collections, and relationship properties, refer to Create Specific Property Types.

Before you can create a new object and persist it to the database, you must Define an SDK Object Model. Then, include that object type in your database schema when you open the database.

Important

Object Types Must Be in Your Schema

You can only write objects whose object type is included in the database schema. If you try to reference or write an object of an object type that isn't in your schema, the SDK returns a schema validation error.

The SDK refers to the base object type as a Realm object. This identifies it as an object type that can be managed by the device persistence layer, Realm database.

For more information about modeling an object, refer to Define an SDK Object Model.

To create a new embedded object instance, assign an instance of an embedded object type to a parent object's property. This can be in a one-to-one, one-to-many, or inverse relationship depending on how you defined the embedded object within the parent object type.

Note

Embedded Objects Must Be Created Within a Parent Object

An embedded object requires a parent object and cannot exist as an independent SDK object.

Embedded objects have strict ownership with their parent object. After you create the embedded object, you cannot reassign it to a different parent object or share it between multiple parent objects.

For more information about modeling an embedded object, refer to Define an Embedded Object.

Asymmetric objects are write-only. Once inserted, the asymmetric object syncs to Atlas. You cannot access the managed data locally, remove it from the database, or query for it.

For information on how to use asymmetric objects in your application, refer to Stream Data to Atlas.

For more information about modeling an asymmetric object, refer to Define an Asymmetric Object.

After you define a geospatial object type, you can use that type to create objects that persist geospatial data.

Initialize objects that use the geospatial data class, and add them to the database like you would any other object type.

The following image shows the results of creating these two company objects:

2 GeoPoints
click to enlarge

For more information about modeling a geospatial object, refer to Define a Geospatial Object.

← 
 →