realm

Realm.IO - Can JSON array be parsed using createOrUpdateAllFromJson?

随声附和 提交于 2019-12-11 03:47:40
问题 Inside Doctor class, I have RealmList - specializationList . public class Doctor extends RealmObject { @PrimaryKey private String doctorId; private FullName fullName; private Age age; private String organizationId; private Position position; private String category; private String loyalty; private RealmList<Specialization> specializationList; private Contacts contacts; private String key; .... Specialization class public class Specialization extends RealmObject{ private String

Realm: Comparing List of primitive types, e.g.: List<String>

独自空忆成欢 提交于 2019-12-11 03:37:19
问题 What is the intended way to compare Realm's list of strings? I'm trying to compare 2 lists of strings in Realm, as follows: func testRealmListOfStrings() { let strings = ["a", "b", "c"] let list1 = List<String>() list1.append(objectsIn: strings) let list2 = List<String>() list2.append(objectsIn: strings) // 1. ok XCTAssertTrue(list1 !== list2, "instances should not be identical") // 2. fails XCTAssertTrue(list1 == list2, "instances should be equal by `==` operator") // 3. fails XCTAssertTrue

NoClassDefFoundError: Failed resolution of: Lio/realm/internal/LinkView

為{幸葍}努か 提交于 2019-12-11 03:23:55
问题 I am using Realm. I installed Stetho-Realm to view realm data. This is what i have done. buildscript { ... repositories { google() jcenter() ... } dependencies { classpath 'com.android.tools.build:gradle:3.1.3' ... classpath "io.realm:realm-gradle-plugin:5.1.0" } } allprojects { repositories { google() jcenter() maven { url 'https://maven.google.com/' } maven { url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo' } } } App gradle stetho:1.5.0 stetho_realm:2.1.0 multidex:1.0.3

updating values in a realm database swift

随声附和 提交于 2019-12-11 03:15:45
问题 I am trying to update the values on a realm database. If a user selects a row containing values I want to be able to update the values of that row. Here is my code but instead of updating, it creates another value in the database func updateTodoList(todoList: TodoListModel, name: String, description: String, createdDate: Date, remiderDate: Date, photo: Data, isCompleted: Bool) -> Void { try! database.write { if name != "" { todoList.name = name } else { todoList.name = "No extra information"

Unable to delete an object in a realm database

我们两清 提交于 2019-12-11 02:33:11
问题 I'm unable to delete an object in a realm database: I have following exception: 0x108196d6f: movq 0x202112(%rip), %rcx ; "exceptionWithName:reason:userInfo:" 0x108196d76: leaq 0x1e6d0b(%rip), %rdx ; @"RLMException" 0x108196d7d: leaq 0x1e71c4(%rip), %rbx ; @"Unable to delete an object not persisted in this Realm." The record is in the database when I check with realm browser!!! Who had the same problem? this is my code: func deleteDatabase() { let realm = RLMRealm.defaultRealm() realm

RealmObject changeListener

泪湿孤枕 提交于 2019-12-11 02:25:17
问题 I'm trying to understand notification types in Realm from the Notifications section in the official docs, and when I'm using RealmObject addChangeListener in multiple managed object all of them are called when only one object is changing. This is my code Person first = realm.where(Person.class).equalTo("id", 0).findFirst(); first.addChangeListener(new RealmChangeListener<Person>() { @Override public void onChange(Person person) { Log.e(LOG_TAG, "First element is changing: " + person); } });

How do you sort a RealmList or RealmResult by distance?

这一生的挚爱 提交于 2019-12-11 02:24:57
问题 Given a RealmObject that has the fields latitude and longitude and you have a RealmList or a RealmResult of such objects. How do you sort by distance by for example your current Location?. Ideas that have sprung to mind are: Add a field calculatedDistance , iterate over all objects and set it. The problem with this approach is that the next time you call copyToRealmOrUpdate(..) you'll overwrite this field with null. Call Collections.sort(...) on the list or result with my own custom

Generating 64 bytes long NSData from key string

a 夏天 提交于 2019-12-11 02:14:23
问题 I think this generates random 64 bytes NSData. uint8_t buffer[64]; SecRandomCopyBytes(kSecRandomDefault, 64, buffer); NSData *keyData = [[NSData alloc] initWithBytes:buffer length:sizeof(buffer)]; I want to generate 64 bytes NSData like this but not a random data. How can I generate 64 bytes NSData with a given key like "com.this.is.akey". Tried this one but it gave me wrong bytes size(not 64 bytes). NSString *base64EncodedString = [[@"somekey.here" dataUsingEncoding:NSUTF8StringEncoding]

Composition over inheritance for RealmObjects with Gson serialization

橙三吉。 提交于 2019-12-11 01:37:59
问题 I'm considering Realm as a database solution for various reasons, but the big one currently being the TransactionTooLargeException now being thrown in Nougat has made it so I have to rework my current database architecture, based on ActiveAndroid, which has its own annoying limitations. The difficulty is that Realm does not support inheritance (https://github.com/realm/realm-java/issues/761) and they don't seem in any particular hurry to get around to it. Instead, they recommend using

Switch from local to synced Realm

拟墨画扇 提交于 2019-12-11 01:37:14
问题 I would like to use the Realm Mobile Platform to provide syncing for my app, but not force the user to register or sign in. I.e., I would like to use a local Realm at first, then switch to a synced Realm if the user decides to use that feature. Is this possible? I couldn't find anything regarding this in the documentation. 回答1: This is possible to do, but you cannot automatically convert a standalone Realm into a synchronized Realm (in the future this could change). Instead, you would create