realm-list

Realm Migration of a String field inside a new RealmList

旧街凉风 提交于 2021-01-04 07:05:31
问题 Conversation class previously had a string field named "message". Now this "message" field is removed and i have added a "RealmList allMessages" inside Conversation class instead of old "message" field. ChatMessage class has a field name "messageText". How can i migrate "message" from Conversation class to "messageText" of list "allMessages"?? public class ChatMessage extends RealmObject implements Parcelable { .... private String messageText; .... } Old Conversation class. public class

Realm Migration of a String field inside a new RealmList

烈酒焚心 提交于 2021-01-04 07:04:03
问题 Conversation class previously had a string field named "message". Now this "message" field is removed and i have added a "RealmList allMessages" inside Conversation class instead of old "message" field. ChatMessage class has a field name "messageText". How can i migrate "message" from Conversation class to "messageText" of list "allMessages"?? public class ChatMessage extends RealmObject implements Parcelable { .... private String messageText; .... } Old Conversation class. public class

Realm: The size of filled RealmList in RealmObject is zero

北城余情 提交于 2020-01-16 18:59:15
问题 Scenario: I have a model(DBBasket) to persist locally, the number of added products and products itself. When the user clicks on the + button under each product thumbnail I'm increasing totalQuantity in Product , Adding the product to the DBBasket , Set totalProducts which I get from server, in DBBasket too. Codes in + button: holder.HomeProductBindGrid.thatPlusButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Product productIns =

Realm add List<> object to already existing object

泄露秘密 提交于 2019-12-25 01:47:24
问题 This is how my Object classes looks like: Workout.swift: class Workout: Object { @objc dynamic var date: Date? // List of exercises (to-many relationship) var exercises = List<Exercise>() } Exercise.swift class Exercise: Object { @objc dynamic var name: String? // List of sets (to-many relationship) var sets = List<Set>() var parentWorkout = LinkingObjects(fromType: Workout.self, property: "exercises") } Set.swift class Set: Object { @objc dynamic var reps: Int = 0 @objc dynamic var kg:

Best practice and how to implement RealmList that need to support different types of objects

爱⌒轻易说出口 提交于 2019-12-24 13:56:25
问题 I have a model 'A' that have a list that can be of type 'B' or 'C' and more. I know Polymorphism is not supported by Realm and i cant just do RealmList<RealmObject> or RealmList<? extends RealmObject> . I just can't figure out how to implement this behavior with Realm. 回答1: Polymorphism support is tracked here: https://github.com/realm/realm-java/issues/761 , but as long as it isn't implemented you have to use composition instead (https://en.wikipedia.org/wiki/Composition_over_inheritance) In

Error deserializing a RealList<RealmString> Into List<String>

我的未来我决定 提交于 2019-12-23 02:20:42
问题 Due to Realm inability to work with promotive types, which include String s, I'm trying to implement a JsonDeserializer just like in this question. The issue is that I'm baffled on to why I'm getting the following error: W/System.err: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING This is part of the Json: "tags": ["GLUTEN FREE", "NUT FREE"], My RealmString: public class RealmString extends RealmObject { private String value; public

Creating managed RealmList outside RealmObject

六眼飞鱼酱① 提交于 2019-12-23 01:15:23
问题 In my app, I have a method that accepts an ArrayList of ID's and returns a RealmList of Machines belonging to these IDs. public RealmList<Machine> getMachinesById(ArrayList<Long> machineIds) { RealmList<Machine> machines = new RealmList<Machine>(); for (int i = 0; i < machineIds.size(); i++){ Machine m = getMachineById(machineIds.get(i)); if (m != null) { machines.add(m); } } return machines; } The getMachineById() function just finds the correct machine for a specific id. I want to filter

Query realm data contained on other object

混江龙づ霸主 提交于 2019-12-23 01:06:11
问题 This question is a follow-up question from: Organize Android Realm data in lists Due to the data returned by the API we use, it's slightly impossible to do an actual query on the realm database. Instead I'm wrapping my ordered data in a RealmList and adding a @PrimaryKey public String id; to it. So our realm data looks like: public class ListPhoto extends RealmObject { @PrimaryKey public String id; public RealmList<Photo> list; // Photo contains String/int/boolean } which makes easy to write

How do i prevent duplicates in RealmSwift List?

∥☆過路亽.° 提交于 2019-12-22 05:24:21
问题 How do I prevent adding duplicates to a list in RealmSwift ? I have my User as a realm object, but the real data source is a server (simply caching the user locally with Realm). When I get the current user data from my server, i want to make sure that my user stored in realm has all the playlists coming from the server (and that their in sync wrt list of tracks and etc.). I'm worried that if i loop over those lists from the server, appending to myUser.playlists , that I may end up adding the

Use React Native Realm to Query through multiple List Objects

橙三吉。 提交于 2019-12-14 03:53:25
问题 First day using React Native and Realm, and I'm having a hard time figuring how to perform a query through two Realm List Objects. Tasks have Reservations , which have Renters , which have first_name and last_name fields. I want my users to be able to search for tasks by the Renter's first and last names. Essentially, "Give me all the tasks whose renter's first or last name begins with "xyz"" const TaskSchema = { name:'Task', properties: { reservations:{ type: LIST, objectType: