Skip to content

Realm Collection #3465

Answered by nirinchev
jbtdevgit asked this question in Q&A
Oct 29, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Realm objects and collections are not copied into memory - instead data is read directly from the database when you read properties/indexes from them and is written directly to the database when you mutate them. This means that, yes, the Realm that owns an object/collection needs to be kept open for the lifetime of the object/collection.

Generally, Realm is not a great fit for a repository pattern, because it relies heavily on lazy-loading and reactivity. You can achieve it by copying the data from the database into unmanaged objects either manually or using automapper, but doing so will lose out on a lot of the benefits of using Realm.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jbtdevgit
Comment options

@papafe
Comment options

papafe Oct 30, 2023
Collaborator

Answer selected by jbtdevgit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants