Docs Menu

Docs HomeRealm

Supported Types - Kotlin SDK

On this page

  • Updating Strings and Byte Arrays

Realm Database supports the following field data types:

  • String

  • Byte

  • Char

  • Short

  • Int

  • MutableRealmInt, which behaves like a Long but also supports increment and decrement methods that implement a conflict-free replicated data type. For more information, see MutableRealmInt.

  • Long

  • Boolean

  • Double

  • Float

  • Decimal128

  • ObjectId

  • RealmInstant

  • Any RealmObject subclass

  • RealmList<T>, where T is any of the supported data types or a RealmObject. Lists of RealmObject cannot have null elements. All other types of RealmList<T> can be nullable (RealmList<T?>).

  • RealmSet<T>, where T is any of the supported data types or a RealmObject. Sets of RealmObject cannot have null elements. All other types of RealmSet<T> can be nullable (RealmSet<T?>).

  • RealmUUID

  • BacklinksDelegate<T>, a backlinks delegate used to define an inverse relationship between RealmObjects.

Note

Importing ObjectId in the Realm Kotlin SDK version 1.5.x or Higher

With the Realm Kotlin Kotlin version 1.5.0 you must import ObjectId from org.mongodb.kbson.ObjectId. If you were using an older SDK version and wish to upgrade, replace your old import statements as io.realm.kotlin.types.ObjectId has been deprecated.

Realm Database stores all non-decimal numeric types as Long values. Similarly, Realm Database stores all decimal numeric types as Double values.

Realm Database does not support fields with modifiers final and volatile, though you can use fields with those modifiers if you ignore them. If you choose to provide custom constructors, you must declare a public constructor with no arguments.

Since Realm Database operates on fields as a whole, it's not possible to directly update individual elements of strings or byte arrays. Instead, you'll need to read the whole field, make your modification to individual elements, and then write the entire field back again in a transaction block.

←  Schemas - Kotlin SDKTimestamps - Kotlin SDK →
Share Feedback
© 2023 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.