Skip to main content

Realm → ObjectBox API Mapping

This quick reference helps you translate common Realm APIs and concepts to ObjectBox equivalents. Use it during migrations together with the full Migration Guide.

Note: Names vary across language bindings (Java/Kotlin, Swift, Dart, Python). When in doubt, check the binding's reference.

Entities / Models

ConceptRealmObjectBoxReference
Define entity/modelopen class Note : RealmObject() (notable exception: RealmObject is an interface in Kotlin!)@Entity class Note { @Id var id: Long = 0 }Realm reference | ObjectBox reference
Index@Index@IndexRealm reference | ObjectBox reference
Ignore field@Ignore@Transient / binding-specificRealm reference | ObjectBox reference

Create / Update

TaskRealmObjectBoxReference
Insertrealm.write { copyToRealm(obj) }box.put(obj)Realm reference | ObjectBox reference
Insert manyrealm.write { copyToRealm(items) }box.put(items) (single TX)Realm reference | ObjectBox reference
Update (by ID)write { findLatest(obj)?.apply{…} }box.put(obj) (same ID)Realm reference | ObjectBox reference

ID behavior: By default, ObjectBox assigns IDs on insert (id == 0). For assignable IDs, mark the ID as assignable in your binding (e.g., @Id(assignable = true) in Java/Kotlin).

Read

TaskRealmObjectBoxReference
Get by IDrealm.query<Note>("id == $0", id).first().find()box.get(id)Realm reference | ObjectBox reference
Get multiple by IDsFilter with INJava/Kotlin: box.get(long[] ids); Dart: getMany(ids)Realm reference | ObjectBox reference
Query by fieldrealm.query<Note>("title == $0", "x")Build a query with conditions (binding API)Realm reference | ObjectBox reference

Delete

TaskRealmObjectBoxReference
Delete by objectwrite { delete(obj) }box.remove(obj)Realm reference | ObjectBox reference
Delete by IDwrite { findLatest(obj)?.let{ delete(it) } }box.remove(id) (returns boolean)Realm reference | ObjectBox reference
Delete manywrite { delete(query.find()) }box.remove(ids or collection) (use a TX)Realm reference | ObjectBox reference

Relations

TypeRealmObjectBoxReference
1:1Field referenceRelation field or ID referenceRealm reference | ObjectBox reference
1:nRealmList<T>ToMany<T> / relation listRealm reference | ObjectBox reference
m:nTwo RealmLists or link objectsRelation entity or reciprocal ToMany (binding-specific)Realm reference | ObjectBox reference

Transactions

TaskRealmObjectBoxReference
Run in TXrealm.write { … }store.runInTx { … }Realm reference | ObjectBox reference
Read-only TXrealm.read { … }Implicit for single ops; explicit TX optionalRealm reference | ObjectBox reference

Vector / Similarity Search (if applicable)

If your migration targets vector/similarity search, ObjectBox supports on-device vector indexing with HNSW in supported bindings. Check the binding documentation for APIs and constraints.

Reference: ObjectBox reference


See also