realm

How to update a list of objects in Realm DB Swift

本秂侑毒 提交于 2019-12-22 12:00:25
问题 I'm trying to find the right way to update a list in a Realm object. For example: class Person: Object { @objc dynamic var id: String = "" let children = List<Child>() } //Adding an item to the list func add(child: Child, _ completion: (DBError?) -> Void) { do { let ctx = try Realm() if let person = ctx.objects(Person.self).last { try ctx.write({ person.children.append(child) completion(nil) }) } catch { completion(DBError.unableToAccessDatabase) } } This seems to work for adding an element.

How to update a list of objects in Realm DB Swift

匆匆过客 提交于 2019-12-22 11:59:13
问题 I'm trying to find the right way to update a list in a Realm object. For example: class Person: Object { @objc dynamic var id: String = "" let children = List<Child>() } //Adding an item to the list func add(child: Child, _ completion: (DBError?) -> Void) { do { let ctx = try Realm() if let person = ctx.objects(Person.self).last { try ctx.write({ person.children.append(child) completion(nil) }) } catch { completion(DBError.unableToAccessDatabase) } } This seems to work for adding an element.

Realm - Swift store a protocol type

拜拜、爱过 提交于 2019-12-22 09:38:52
问题 I have the following structure: class Entity : Object { dynamic var Id = 0 dynamic var Title = "" dynamic var Subtitle = "" var atttribute : MyProtocol? } Is there a way of storing something in attribute? Today is returning nil. If I add dynamic it returns the error: Property cannot be marked dynamic because its type cannot be represented in Objective-C Is there any way to store properties that conform to a Protocol as that? 回答1: No. Realm properties are monomorphic, and Realm needs to know

React Native + AWS AppSync - maximum data storage

被刻印的时光 ゝ 提交于 2019-12-22 09:27:26
问题 I’m building an offline application which needs to store around 30,000 records. Will AWS AppSync have any performance issues with a data set of this size? I’ve used redux w/ redux-persist in the past, which saves the store offline, then refetchs and places in memory when the app launches. This causes fairly huge memory issues, especially when querying the data. I’m wondering if AppSync has the ability to use Realm or SQLite for offline storage and querying. Thanks. 来源: https://stackoverflow

How to handle Realm React Native migrations and schemaVersion on iOS?

倖福魔咒の 提交于 2019-12-22 08:38:02
问题 Before I fall in love with realm on react-native and iOS, I am trying to learn more about how I can handle migrations. This statement has me concerned: Realm React Native 0.10.0 https://realm.io/docs/react-native/latest/#migrations Migrations are currently limited to updating the schema and schemaVersion when opening a Realm as outlined above. Data migrations are not yet supported but may be added in the future. I understand this to mean I need to increment schemaVersion each time I make a

How to handle sync error: “Bad changeset received: Assertion failed: left().link_target_table_ndx == right().link_target_table_ndx”

寵の児 提交于 2019-12-22 07:56:30
问题 I got this error on the object server console on login and can't sync anymore. The same user account was working before. 2016-12-13T13:20:52.858Z - error: sync-server: Connection[6]: Session[1]: Bad changeset received: Assertion failed: left().link_target_table_ndx == right().link_target_table_ndx (message_type='upload') 2016-12-13T13:20:52.858Z - info: sync-server: Connection[6]: Session[1]: Session terminated (session_ident=1). 2016-12-13T13:20:52.858Z - info: sync-server: Connection[6]:

Gson deserialization for Realm list of primitives

别说谁变了你拦得住时间么 提交于 2019-12-22 06:49:05
问题 I am using realm with gson. I have a modal which has a list of int type field. Realm does not support currently list of primitives. To solve this there is a solution. I created my RealmInt class. import io.realm.RealmObject; public class RealmInt extends RealmObject { private int val; public int getVal() { return val; } public void setVal(int val) { this.val = val; } } I have a big modal object something like that.. public class Product extends RealmObject { @PrimaryKey private int productID;

How to fake Realm Results for tests

吃可爱长大的小学妹 提交于 2019-12-22 06:45:11
问题 I have written a test to validate if a function is called : func test_getTaskLists_doNotCreateOrUpdateTaskListToStorageWhenSynchedLocally() { ... let (datasource, restAPI, fakeTaskListStorage) = ... datasource.getTaskLists() { (taskLists, error) -> Void in ... XCTAssertEqual(1, fakeTaskListStorage.readAllInvocationCount) ... } ... } The function is mocked to bypass super implementation and the issue is that the function returns a Results which I can't figure out to build/mock in order to

Create a realm object during a Realm Migration

末鹿安然 提交于 2019-12-22 05:59:07
问题 Are you able to create a realm Object during a migration? I am wanting to extract part of an existing realm object and create a new object with that data, but the migration always hangs up. Here is my migration code private class var migrationBlock: MigrationBlock { return { migration, oldSchemaVersion in if oldSchemaVersion < 1 { print("Shema Version 0") migration.enumerate(Transaction.className(), { (oldObject, newObject) -> Void in let oldDate = oldObject!["date"] as! NSDate let

Remove Realm Model Object from Xcode

こ雲淡風輕ζ 提交于 2019-12-22 05:28:14
问题 Ages ago, I used Realm with iOS projects, but am no longer doing so. However, I still have the template available in Xcode as seen here: It was never an issue until the Xcode 11 beta, where every time I run a project, I get the following in my console: error: module importing failed: invalid token (rlm_lldb.py, line 37) File "temp.py", line 1, in At this point, I'd just like to remove it, but I cannot find any documentation on how to do it from Realm. 回答1: Xcode keeps it's custom templates at