realm

Realm.open vs new Realm

早过忘川 提交于 2019-12-04 10:44:37
In the context of a React Native app, using Realm locally only (so no realm object server for now). What is the difference between opening a realm using Realm.open({schema: [Car, Person]}) and creating a new Realm instance with new Realm({schema: [Car, Person]}); When should I use one or the other? Looks like Realm.open is just a callback to make sure the syncronisation is done, so only needed for synced Realms? So far this is what I found: Realm.open: According to the doc reference Realm.open means "Open a Realm asynchronously with a promise. If the Realm is synced, it will be fully

Anonymous user in Realm Mobile Platform

孤人 提交于 2019-12-04 10:44:11
Can I connect to a remote Realm without having to login? In Swift, the only way to create a synchronizable Realm is through the syncConfiguration property of a Realm.Configuration . Is there a method for getting an anonymous User so that anyone can connect to the remote Realm? marius Can I connect to a remote Realm without having to login? No, you always need to be authenticated. Is there a method for getting an anonymous User so that anyone can connect to the remote Realm? Yes, via SyncCredentials.anonymous() . This is now possible in Realm Cloud . Here's how I am doing it in Swift: if let

Install Realm in a Swift App

不打扰是莪最后的温柔 提交于 2019-12-04 10:25:23
I am trying to add Realm to my app written in swift. I have followed the tutorial and I can't seem to get it to work. The biggest problem is that when I try to import Realm I get No such module 'Realm' I don't know what else to try. You can see my efforts below. You can see the instructions here: http://realm.io/docs/cocoa/0.85.0/#swft I have also copied the instructions below: Due to the current lack of proper infrastructure for Swift dependency management, using Realm in your project requires the following steps: Add Realm as a submodule by opening the Terminal, cd-ing into your top-level

Why is Realm so fast compared to SQLite?

白昼怎懂夜的黑 提交于 2019-12-04 10:17:59
问题 I have seen the benchmarks on the Realm website, how come Realm is so fast compared to SQLite, which has a long development history, being released back in 2000? I was wondering if someone with knowledge could share some general techniques that Realm uses underneath the hood in the database layer? As of March, 2016, only the bindings are open-sourced and the db layer is still closed off. 回答1: The Realm blog has great technical talks on the subject, but there was no single repository that goes

Realm: Map JSON to Realm-Objects with Alamofire

荒凉一梦 提交于 2019-12-04 09:52:57
I would like to use Realm and Alamofire to map JSON to my database objects. Are there good tutorials out there? Realm offers built-in limited capabilities of mapping arbitrary JSON structures to RLMObjects . But there are some good third-party libraries, which could assist you with your use-case. You might want to checkout these: Realm-JSON (Objective-C), which offers a declarative, Mantle like way of defining your mapping ObjectMapper (Swift), which offers Realm and Alamofire support 来源: https://stackoverflow.com/questions/33479733/realm-map-json-to-realm-objects-with-alamofire

Adding a primary key to a RLMObject requires migration, any ideas how?

孤街浪徒 提交于 2019-12-04 09:52:26
I'm working on an iOS app with Realm.io as the persistent store. I've just updated one of my custom RLMObject subclasses by adding a primary key. When I run the app, I get an error telling me I need to add migration steps: 'Migration is required for object type 'MY_REALM_OBJECT' due to the following errors: - Property 'property_name' has been made a primary key.' I have other migration code but can't find anything in the Realm docs on how to add a primary key to an RLMObject. Anyone know how to do this? You need to use the key "primaryKeyProperty" and set the value to the RLMObject property

Realm Cocoa: finding multiple objects by PKs

谁说我不能喝 提交于 2019-12-04 09:36:12
Long time lurker, first time asker. I'm using Realm Cocoa (from Realm.io) in a project and am struggling to perform searches by PKs. Let's say I have an entity called RLMFoo which has a primary key called bar . I also have a list of PKs, let's say stored in an array: NSArray *primaryKeys = @[@"bar1", @"bar2", @"bar3"] Is there any way to retrieve all entities of class RLMFoo from my realm in one single query? I've tried so far: Predicate with format: [RLMFoo objectsInRealm:realm withPredicate:[NSPredicate predicateWithFormat:@"bar IN %@", primaryKeys]]; Realm's where: [RLMFoo objectsInRealm

How to get item with max id?

荒凉一梦 提交于 2019-12-04 09:31:50
I'm tryig to get the ítem with max id using this query realm.objects(Entity).filter("@max.id").first It's throwing an error saying that can't parse query so it seems this is not the correct way to do it. How can I write this query on Realm for Swift? Filters alone cannot do what you're after as they only consider a single top-level object at a time. Beyond that conceptual issue, there are a few issues with the code you posted: @"@max.id" is not a valid NSPredicate format string . NSPredicate format strings must be composed of comparisons between expressions, not expressions on their own.

Save image in Realm

孤街浪徒 提交于 2019-12-04 08:19:11
I'm trying to pick image from device's Photo Library in method: func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { userPhoto.image = info[UIImagePickerControllerOriginalImage] as! UIImage? userPhoto.contentMode = .scaleAspectFill userPhoto.clipsToBounds = true dismiss(animated: true, completion: nil) } and save this picture in Realm (as NSData): asset.assetImage = UIImagePNGRepresentation(userPhoto.image!)! as NSData? ... try! myRealm.write { user.assetsList.append(asset) myRealm.add(user) } After build succeeded and trying to

Realm Android exception occured during performFiltering()!

对着背影说爱祢 提交于 2019-12-04 06:44:18
问题 The app worked fine when I used Spinner. But when I tried AutoComplete Textview instead of Spinner, nothing is displayed when I type on it. Any help is appreciated. Logcat Warn: 08-23 14:01:13.485 9542-9542/com.vyshnav.realmexample W/art: Failed to find OatDexFile for DexFile /data/data/com.vyshnav.realmexample/files/instant-run/dex/slice-slice_9-classes.dex ( canonical path /data/data/com.vyshnav.realmexample/files/instant-run/dex/slice-slice_9-classes.dex) with checksum 0x0486ffcc in