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
40
votes
4 answers

How can I easily delete all objects in a Realm

I have the choice of doing a migration, but I would prefer to delete everything in my defaultRealm(). How can I do this easily? realm.deleteObject(object) is the only function along with .deleteObjects. I have tried the following code: Method…
CaptainCOOLGUY
  • 1,131
  • 1
  • 14
  • 26
39
votes
6 answers

How do I set a auto increment key in Realm?

I have a unique msgid for each ChatData object. @interface ChatData : RLMObject @property NSInteger msgid; .... @end But each time I create a new object I have to query all objects and get the last msgid. RLMArray *all = [[ChatData allObjects]…
drinking
  • 1,533
  • 3
  • 15
  • 22
37
votes
4 answers

Realm accessed from incorrect thread - again

I noticed many problems with accessing realm object, and I thought that my solution would be solving that. So I have written simple helping method like this: public func write(completion: @escaping (Realm) -> ()) { DispatchQueue(label:…
Tajnero
  • 583
  • 1
  • 5
  • 12
36
votes
2 answers

Kotlin data class of RealmObject

I'm using Kotlin and Realm to write a data class data class AuthToken(val register: Boolean, val token: String, val tokenSecret: String, val user: AuthUser) I have to save the data to…
Allen Vork
  • 1,536
  • 3
  • 16
  • 29
36
votes
2 answers

Xcode unable to find strip-frameworks.sh directory

I recently update Xcode to Version 7.1, which included Swift 2.1. I installed Swift 2.1 with no troubles. After attempting to run my project, I realized that I needed to grab the latest version of Realm, since the previous version did not support…
CodeIt
  • 769
  • 2
  • 7
  • 16
35
votes
3 answers

composite primary key realm/swift

I'm new to swift and realm. I want to make a composite primary key and when I'm trying something like this : class DbLocation : Object { dynamic var id = 0 dynamic var tourId = 0 dynamic var uuid : String { return "\(id)\(tourId)" } …
halfred
  • 777
  • 1
  • 9
  • 16
33
votes
2 answers

How to update an object in Realm Swift

I'm trying to learn how to use Realm Swift and Charts so I can eventually use them both in an app I'm building and I'm having a hell of a time figuring out Realm. Eventually, I'm planning on having Charts look at my Realm DB and then display the…
jammyman34
  • 1,399
  • 4
  • 15
  • 22
33
votes
9 answers

How to set primary key auto increment in realm android

I want to set primary key auto increment for my table. Here is my Class. I have set primary key but I want it to be auto increment primary key. public class users extends RealmObject { @PrimaryKey private int id; private long icn; private String…
Maaz Patel
  • 756
  • 2
  • 7
  • 20
32
votes
2 answers

How to put an image in a Realm database?

I'm writing an iOS application using Swift 2 and I would like to save profile picture of an account locally in a Realm database. I can't find any documentation or people talking about that. Is it possible? And how? May be is it bad to do that?
VivienG
  • 2,143
  • 3
  • 24
  • 43
31
votes
2 answers

How to sort using Realm?

I don't know how to sort using Realm. My current code is. data = realm.objects(WorkoutSet) data = data!.sorted("date") I want to sort date an Int from high numbers to low numbers. The docs need more information and the GitHub link throws a 404…
Cody Weaver
  • 4,756
  • 11
  • 33
  • 51
31
votes
2 answers

Realm error: Invalid Value, expecting int and receiving: 0

I am using Realm with Swift for a query, but am receiving this error: Terminating app due to uncaught exception 'Invalid value', reason: 'Expected object of type int for property 'id' on object of type 'JournalEntryLine', but received: 0' The…
Jared
  • 313
  • 3
  • 4
31
votes
5 answers

Order by multiple properties using Realm

How can I order my Realm results using multiple properties? I'm sorting them first using one property like this: allShows = Show.allObjects().sortedResultsUsingProperty("dateStart", ascending: true) But now I also want to do a secondary sort by…
codeman
  • 8,868
  • 13
  • 50
  • 79
30
votes
6 answers

Why does Realm use try! in Swift?

Why Does Realm use try! so frequently? It seems like if you're certain your call won't fail then you should not design it to throw - no? Here is an example, from the Swift page on realm.io: // Get the default Realm let realm = try! Realm() or //…
Jason Leach
  • 3,889
  • 7
  • 37
  • 54
29
votes
1 answer

Using Realm in React Native app with Redux

I am about to undertake the development of a React Native app and am thoroughly convinced of the benefits of managing the app's state using Redux, however I'd like to make the app's data available whilst offline by using Realm for persistent…
oldo.nicho
  • 2,149
  • 2
  • 25
  • 39
29
votes
2 answers

Right way of doing Realm Migration Android

We use Realm for our app. Our app has been beta released. Now I want to add a field to one of our realm objects. So I got to write RealmMigration and I wrote one too. The Question here is how to apply this Realm migration to my app. I use…
User
  • 1,186
  • 4
  • 22
  • 36