realm-list

Organize Android Realm data in lists

廉价感情. 提交于 2019-12-14 03:49:28
问题 I'm looking into migrating our current app to realm and trying to figure out what's the best way to organize the data into ream. For this question I'll focus on the Photo object of my data model (but there're others). All my data objects arrive from an API with endpoints such as: getPopular() , getNearbyPhotos(lat, lng) , getUserPhotos(userId) , getAlbumPhotos(albumId) , getCollection(type) . On most of those endpoints there're further parameters such as sort=best/chronological . We're

updating an array of items in realm swift

杀马特。学长 韩版系。学妹 提交于 2019-12-11 19:20:12
问题 I am trying to update the content of a real database which takes an array. I would like to update the array stored in it below is my code for it class TodoListModel: Object { @objc dynamic var id = UUID().uuidString let photos = List<Data>() @objc dynamic var createdDate: Date? override static func primaryKey() -> String? { return "id" } let parentCategory = LinkingObjects(fromType: CategoryModel.self, property: "items") } In this case, the new Data just gets added instead on replacing the

How to query List<Int> on Realm Swift

久未见 提交于 2019-12-11 17:42:46
问题 How can I filter out the RealmFilter.objectIds that has a given Int? func delete(ids: [Int]) { let filterResultsToDelete = realm.objects(CRMRealmFilterResult.self).filter("ANY objectIds IN %@",ids) //Crashes } class RealmFilterResult : Object { @objc dynamic var filterId: Int = 0 let objectIds = List<Int>() override static func primaryKey() -> String { return "filterId" } } 回答1: This may not be at all what you want but it was a good exercise. Maybe this will help. Let me re-state what I think

Add array of json (which contain inner array) in realm using swift

拟墨画扇 提交于 2019-12-11 06:07:08
问题 I have created API which generate JSON, that JSON looks like this [ { "id": 105, "date": "2018-09-06T22:37:57", "date_gmt": "2018-09-06T17:07:57", "guid": { "rendered": "http://wh2.6ae.myftpupload.com/?p=105" }, "modified": "2018-09-06T22:37:57", "modified_gmt": "2018-09-06T17:07:57", "slug": "video-post-20", "status": "publish", "type": "post", "link": "http://wh2.6ae.myftpupload.com/video-post-20/", "title": { "rendered": "Video post – 20" }, "content": { "rendered": "", "protected": false

Realm List not stored in Swift 4.2 in release config

那年仲夏 提交于 2019-12-10 23:18:48
问题 I've just built the latest version of my app, and have run into a problem where the List s on all of my realm objects are not being stored. Here is some sample code: Object: public class ReportItem: Object { @objc dynamic var id: String! @objc dynamic var someDate: Date? // This contains another List as one of its properties let list = List<OtherRealmObject>() override public class func primaryKey() -> String { return "id" } convenience public init(id: String, date: Date) { self.init() self

Realm, network operations, subscribing and observing on different threads with RxJava

独自空忆成欢 提交于 2019-12-09 07:18:03
问题 I need to : Fetch some data from an API on a background thread Display the data on the UI Save to Realm. fetchItemsFromServer().subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<ItemList>() { @Override public void call(ItemList items) { displayItems(items); try { realm.beginTransaction(); realm.copyToRealmOrUpdate(itemList); realm.commitTransaction(); Logger.v("Realm ", "Copied list object to realm"); } catch (Exception e) { Logger.e("Realm

Android Realm Handling Primary Key in Relational Object

旧巷老猫 提交于 2019-12-08 09:57:35
I have two objects: MailBox and Email . Each Receiver has many Emails . public class MailBoxRealmModel extends RealmObject { @PrimaryKey private long id; private String name; private String mailboxId; private RealmList<EmailRealmModel> emails; } public class EmailRealmModel extends RealmObject { @PrimaryKey private long EmailId; private String Name; private String Text; private String Tag; private int Type; private String Time; private int Status; } How can one use **realm.insertOrUpdate** when adding email to MailBoxRealmModel? EmailRealmModel email = new EmailRealmModel(); email.setMessageId

Android Realm Handling Primary Key in Relational Object

橙三吉。 提交于 2019-12-08 03:10:17
问题 I have two objects: MailBox and Email . Each Receiver has many Emails . public class MailBoxRealmModel extends RealmObject { @PrimaryKey private long id; private String name; private String mailboxId; private RealmList<EmailRealmModel> emails; } public class EmailRealmModel extends RealmObject { @PrimaryKey private long EmailId; private String Name; private String Text; private String Tag; private int Type; private String Time; private int Status; } How can one use **realm.insertOrUpdate**

RealmList of String Type in Android

最后都变了- 提交于 2019-12-06 18:31:19
问题 I'm using Realm for Local storage in Android. I'm getting following response form server. [{ "ListId": 10, "Names": ["Name1", "Name2", "Name3", "Name4"] }] Here is my Model public class Model extends RealmObject { private int ListId; private RealmList<String> Names = new RealmList<String>() public int getListId() { return ListId; } public void setListId(int listId) { ListId = listId; } public RealmList<String> getNames() { return Names; } public void setNames(RealmList<String> names) { Names

How to add a nested List of objects in Realm “Error: JS value must be of type: object”

青春壹個敷衍的年華 提交于 2019-12-06 15:33:46
问题 I'm trying to create Realm database that has a json array of objects with a nested array of objects. When I try to add using the code below I always get the error: JS value must be of type: object. Schemas: import Realm from 'realm'; class Exercise extends Realm.Object { } Exercise.schema = { name: 'Exercise', primaryKey: 'id', properties: { id: 'int', name: 'string', category: 'string', bodyPart: 'string', levels: {type: 'list', objectType: 'Level'} } }; class Level extends Realm.Object { }