How do I set a auto increment key in Realm?

Realm doesn’t have auto increment behavior, so you’ll need to manage that yourself. A question I’d encourage you to ask yourself about your data: Is it necessary to have sequential, contiguous, integer ID’s? If not, then a unique string primary key might be sufficient. Then you can use something like [[NSUUID UUID] UUIDString] to generate … Read more

Clear complete Realm Database

Update: Since posting, a new method has been added to delete all objects (as jpsim has already mentioned): // Obj-C [realm beginWriteTransaction]; [realm deleteAllObjects]; [realm commitWriteTransaction]; // Swift try! realm.write { realm.deleteAll() } Note that these methods will not alter the data structure; they only delete the existing records. If you are looking to alter … Read more

Primary key property ‘name’ does not exist on object ‘RealmSwiftPermissionRole’

There’s an issue with iOS 13 and Xcode 11 which may cause this problem. All String properties of Realm classes with a default String value set are disregarded somehow. You can fix this by updating to the latest version (currently 3.20.0) and then on Xcode: Product -> Clean Build Folder. If you’re using cocoa-pods: Open … Read more

“realm migration needed”, exception in android while retrieving values from realm db

EDIT: for new versions of Realm, Realm.init(Context context) is added Realm.init(context); RealmConfiguration config = new RealmConfiguration .Builder() .deleteRealmIfMigrationNeeded() .build(); NOTE: With this config option, any schema change will result in loss of data, specifically: a field is added/removed a new RealmObject class is added an existing RealmObject is removed @Required is added/removed @PrimaryKey is added/removed … Read more

How to set primary key in Swift for Realm model

As of Realm Swift v10.10.0, you declare a primary key with @Persisted(primaryKey: true): class Foo: Object { @Persisted(primaryKey: true) var id = 0 @Persisted var title = “” } Older versions: primaryKey needs to be a class function which returns the name of the property which is the primary key, not an instance method which … Read more

How to delete object from Realm Database Android?

In 0.88.3 and below you can do: realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { RealmResults<Message> rows = realm.where(Message.class).equalTo(Message.USER_ID,userId).findAll(); rows.clear(); } }); From 0.89 (next release) this will be deleteAllFromRealm() instead. realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { RealmResults<Message> result = realm.where(Message.class).equalTo(Message.USER_ID,userId).findAll(); result.deleteAllFromRealm(); } });

Do I understand MongoDB Realm correctly?

below are some notes for your questions. I’m just getting setup with MongoDB and Realm, myself. A – Tools Realm Database: Local Storage & Persistence Correct – Client (on-device / local) storage Realm Sync: Sync Realm Databases between clients and the Mongo DB Atlas Somewhat confusingly, there’s 2 different implementations of Realm Sync: Realm Sync … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)