Questions tagged [realm]

Realm, formally known as MongoDB Realm, is an object-oriented database widely used as an alternative to SQLite & ORMs that includes a built-in device-to-cloud data sync. Realm supports a variety of platforms including Android, iOS, Linux, macOS, and Windows.

Realm formally known as MongoDB Realm, is an object-oriented database widely used as an alternative to CoreDate, SQLite & ORMs. Realm supports a variety of platforms including Android, iOS, Linux, macOS, and Windows.

Realm can be used as a local-only data store or synchronized to MongoDB’s multi-cloud database platform Atlas via a built-in, real-time device-to-cloud sync service – Realm Sync.

Originally released in 2016, Realm was acquired by MongoDB in 2019. It remains open source under the Apache License.

Useful Links

9370 questions
29
votes
2 answers

Optional Int in Realm

I am trying to use an Optional Int in Realm and am getting an old error I think. Code dynamic var reps: Int? = nil Error 'Property cannot be marked dynamic because its type cannot be represented in Objective-C' I am using Realm 0.96.1 with XCode…
Cody Weaver
  • 4,756
  • 11
  • 33
  • 51
29
votes
3 answers

How to deliver app with prefilled realm-database

I would like to deliver my app with already prefilled data in my realm database. Do I have to simply copy it to the documents directory or is there some other things to do?
swalkner
  • 16,679
  • 31
  • 123
  • 210
29
votes
5 answers

Best practices to use realm with a recycler view?

Do you guys have any best practices regarding using realm with a recyclerview ? I know it's generic question but I found nothing on it on the internet. For example I run into a lot of troubles trying to implement a simple color change on a row . For…
Anghelut Florin
  • 301
  • 1
  • 3
  • 4
27
votes
6 answers

How can I easily duplicate/copy an existing realm object

I have a Realm Object which has several relationships, anyone has a good code snippet that generalizes a copy method, to create a duplicate in the database.
mvo
  • 669
  • 1
  • 6
  • 11
27
votes
10 answers

How to convert RealmResults object to RealmList?

I have a RealmResults object. I want to convert it to RealmList object. any suggestions?
Ezio123
  • 376
  • 1
  • 4
  • 11
27
votes
8 answers

Realm and auto increment Behavior (Android)

I'm trying to get data from Realm using an ID as a reference. However, when querying for an ID, I've found that Realm is giving me the same ID for all elements (ID of 0). Why doesn't the ID auto-increment when I use the @PrimaryKey annotation on the…
Bachlet Tansime
  • 1,273
  • 3
  • 12
  • 17
26
votes
5 answers

How can I store a Dictionary with RealmSwift?

Considering the following model: class Person: Object { dynamic var name = "" let hobbies = Dictionary() } I'm trying to stock in Realm an object of type [String:String] that I got from an Alamofire request but can't since…
gabuchan
  • 785
  • 1
  • 7
  • 18
26
votes
4 answers

Gson deserialization of List into realmList

I'm using retrofit with gson to deserialize my json into realm objects. This works very well for the most part. Trouble arises when dealing with RealmList(String(or any other basic data type)) Since Realm doesnt support RealmList where E doesnt…
avid
  • 407
  • 1
  • 5
  • 11
25
votes
1 answer

Realm vs Sqlite for mobile development

Am an Xamarin Developer , I used to use Sqlite as mobile database , recently Realm comes to the picture. Any idea about Differences between them in Performance & ease of use..etc? What is the best practice of using either one?
Medo Medo
  • 952
  • 2
  • 12
  • 21
25
votes
3 answers

Prevent Realm from overwriting a property when updating an Object

I've setup a REST API to realm object in iOS. However I've found an issue with creating a favorite flag in my object. I've created a favorite bool, however everytime the object is updated from the API it sets the favorite to default false again.…
Peter Pik
  • 11,023
  • 19
  • 84
  • 142
24
votes
3 answers

Enums support with Realm?

I'm working on an android app and Realm, and I need to create an enum attribute for one of my objects; but I discovered in this post that Realm doesn't support enum yet. My object is like this: public class ShuttleOption extends RealmObject { …
MJB22
  • 358
  • 1
  • 3
  • 10
24
votes
2 answers

How to Clear Database in Realm in Android

I want to clear whole database when a user press logout button and loads a new data when another user login.I tried many solutions like try { Realm.deleteRealm(realmConfiguration); } catch (Exception ex){ throw ex; …
Nicks
  • 3,188
  • 3
  • 25
  • 29
24
votes
2 answers

Dynamic properties in Realm

I am starting to work with Realm on iOS 8 or greater and looking at the documentation in Realm. I noticed that all of the properties have the dynamic keyword in front of them. Is that required in Realm? I have read the Apple documentation on the…
Cody Weaver
  • 4,756
  • 11
  • 33
  • 51
23
votes
4 answers

Realm access from incorrect thread

I have an application with a LoginActivity, that when the user login correctly, I register to receive messages. And the LoginActivity jumps to MainActivity. The arriving messages are supposed to be stored in database (Realm), to recover from a Realm…
Shudy
  • 7,806
  • 19
  • 63
  • 98
22
votes
8 answers

Swift Remove Object from Realm

I have Realm Object that save list from the JSON Response. But now i need to remove the object if the object is not on the list again from JSON. How i do that? This is my init for realm func listItems (dic : Array<[String:AnyObject]>) ->…
Voyager
  • 399
  • 1
  • 8
  • 15