Realm Object Model
Parent: MongoDB Atlas Device SDK · Published reference · snapshot 2026-10-24 · skill mongodb-cohort-0ecd8d6fb6f0
↓ Facts as markdownall context files
Source-anchored research for Realm Object Model. Run status: COMPLETED.
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
How it works
- In the inspected Swift Object implementation, @Persisted marks stored properties; properties without that wrapper are ignored when using this declaration style. @Persisted(primaryKey: true) declares the primary key, whose values enforce uniqueness and receive an automatic index. (low confidence) [source]
Comparisons and alternatives
- Realm models persisted data with typed classes and properties: Swift subclasses Object, while the Java example subclasses RealmObject. Application code works with model instances rather than manually mapping each value to relational rows. (high confidence) [source]
- An embedded Realm object has exactly one parent and no primary key. It is created through its parent rather than added as an independent top-level object. Deleting its parent deletes the embedded object; Swift also deletes it when the parent removes its owning link. (high confidence) [source]
Facts and statements
- Realm object models support relationships through references to other model objects and typed collections. The inspected Swift implementation also exposes LinkingObjects for inverse links, alongside List, MutableSet, and Map collections. (medium confidence) [source]
- A newly instantiated Swift Realm object can be unmanaged. Adding it to a Realm makes it managed; subsequent persisted mutations must occur inside a write transaction. (high confidence) [source]
- Historical Swift and Java tutorials describe live managed objects and query results that reflect changes to their underlying database. Change observation can drive UI updates without repeatedly copying records out of the database. (high confidence) [source]
- Embedded objects express exclusive ownership: one parent owns the embedded object, and removing that parent's reference or deleting the parent deletes it. The Swift implementation and .NET changelog both prohibit sharing the same managed embedded instance between multiple parents. (high confidence) [source]
- Swift frozen objects are immutable snapshots that do not advance with subsequent writes and can be read across threads. Live objects have thread or actor confinement requirements, so a stored object reference is not automatically safe to pass between execution contexts. (high confidence) [source]
- Realm Kotlin's 0.4.0 release notes, dated 2021-07-13, explicitly changed its architecture from thread-confined live objects to frozen objects. Results outside write transactions became frozen, updates arrived through Flows, and MutableRealm.findLatest supplied a mutable live version inside a write transaction. (low confidence) [source]
- Retaining frozen objects while continuing to write can pin old database versions and increase file size. Swift source documentation and the Kotlin changelog both warn about this retention cost; frozen references should not be treated as cost-free long-lived value copies. (high confidence) [source]
- A March 2022 .NET issue reports invalidated collection access with nested Xamarin collection views and background updates. Its reduced example produces RealmInvalidObjectException after collection deletion or Realm closure; the reporter explicitly says that example does not reproduce the separate Access to invalidated Collection object exception. (low confidence) [source]
- Realm model declarations define persisted fields in application code. Swift uses Object subclasses with @Persisted properties; the Android Java tutorial uses RealmObject subclasses with annotations such as @Required and @PrimaryKey. These SDK syntaxes should not be treated as interchangeable. (high confidence) [source]
- Realm models represent relationships through object-valued properties and typed collections. Swift supports links to Object subclasses and List collections; the Java tutorial demonstrates RealmObject and RealmList fields for relationships. (high confidence) [source]
- In Swift, constructing an Object produces an unmanaged instance; Realm.add makes it managed. Its realm property is nil while unmanaged. Java also distinguishes managed proxy objects from unmanaged model instances. (high confidence) [source]
- Primary keys provide object identity and enforce uniqueness within a model type. Swift documents automatic primary-key indexes and @Persisted(primaryKey: true); the Java tutorial demonstrates an annotated primary key and explains its indexing behavior. Supported key types depend on the SDK. (high confidence) [source]
- Live managed objects have thread or execution-context restrictions. Swift and Java expose frozen immutable snapshots that can be read across threads; these snapshots do not behave as mutable, automatically advancing live objects. Retaining old frozen versions while writing can increase the Realm file size. (high confidence) [source]
- Managed Realm objects support change observation, but live does not mean synchronous cross-thread notification. Swift delivers changes after the managing Realm advances to the relevant version, and a blocked run loop can delay or coalesce callbacks. (high confidence) [source]
- Deleting a managed object invalidates its accessors. Swift exposes isInvalidated and Java exposes isValid; applications must check object validity before accessing a retained reference after deletion. (high confidence) [source]
- The Android tutorial requires create, update, and delete operations on persisted Realm data to run inside write transactions. Committing persists the transaction; cancelling discards its changes. (low confidence) [source]
- In a hands-on Android forensic example published November 20, 2019, the researcher recovered name and age values from default.realm and inspected them with Realm Studio. This establishes a concrete local persistence example, not a guarantee about every application file location or format version. (low confidence) [source]
Children
- Realm embedded-object ownership (frontier)
- Realm live and frozen objects (frontier)
- Realm relationship collections (frontier)
- Realm managed-object lifecycle (frontier)
- Managed and unmanaged Realm objects (frontier)
- Embedded object ownership (frontier)
- Realm object identity and primary keys (frontier)
- Live objects and frozen snapshots (frontier)
Frontier under this node: Embedded object ownership, Live objects and frozen snapshots, Managed and unmanaged Realm objects, Realm embedded-object ownership, Realm live and frozen objects, Realm managed-object lifecycle, Realm object identity and primary keys, Realm relationship collections