realm

Realm : How to structure one to many relationship

為{幸葍}努か 提交于 2019-12-11 07:04:39
问题 I have been looking over to many ORM's in android, by far what i have used and would fit to my app so far are ActiveAndroid and SugarOrm, but what i need is not currently supported(not supported but can be fix by creating sql scripts) as of now (one-to-many relationship). Im looking at Realm ORM for android a very promising one. Is this possible with Realm? // this is just a sample of what i need to do., // parent class Message{ long id; List<Meta> messages; } // child class Meta{ long

Proguard with Parceler and Realm

断了今生、忘了曾经 提交于 2019-12-11 06:54:27
问题 I'm using Realm and Parceler and everything is working fine but when I enable the Proguard I'm getting an error when doing: Parcels.wrap(obj) I'm getting the following error: org.parceler.ParcelerRuntimeException: Unable to find generated Parcelable class for io.realm.g, verify that your class is configured properly and that the Parcelable class io.realm.g$$Parcelable is generated by Parceler. Although I have configured the proguard rules like: ##---------------Begin: proguard configuration

Object Type xxx is not found in schema

陌路散爱 提交于 2019-12-11 06:38:19
问题 Firstly, i defined the TestSchema first, and create "let realm = new Realm({schema: [TestSchema]})",and the result for {realm.objects('Test').length} is right. When i try to add more schemas into realm, e.g.'let realm = new Realm({schema:[TestSchema, CarSchema, PersonSchema]})', it shows the wrong msg. "Object Type Car is not found in schema". I was wondering what's going on here. 回答1: Put all these schema definitions in one file, say realm.js, and export these schemas. You can check this.

Android how to save realm results with onSaveInstanceState for screen rotation

时间秒杀一切 提交于 2019-12-11 06:36:46
问题 My problem is this: When i open dialog fragment, i send realm and realm results from activity to dialog fragment. I always send different realm results to dialog fragment, depending what i click in activity. This is code in dialog fragment where i receive realm and realmResults from activity, when i click to open dialog fragment: public void setChangeNoteListener(ChangeNoteListener mChangeNoteListener, RealmResults<Drop> realmResults, Realm realm) { mNotelistener = mChangeNoteListener;

When trying to executeTransactionAsync, it returns error in Realm

冷暖自知 提交于 2019-12-11 06:36:18
问题 When trying to executeTransactionAsync, it returns error like 'MODEL = Method threw 'java.lang.IllegalStateException' exception. Cannot evaluate io.realm.ModelRealmProxy.toString()'. Also when I am fetching and debug it, it displays data something like below image public class AsyncTaskExample extends AppCompatActivity { List<Student> mStudentCount; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_async_task

RLMException', reason: 'Attempting to modify object outside of a write transaction

北城余情 提交于 2019-12-11 06:30:37
问题 I've encountered following error when I've complied following code: *** Terminating app due to uncaught exception 'RLMException', reason: 'Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first.' for outlet in brand.outlets! { let outl = OutletListRealm() outl.outletId = outlet.id outl.outletName = outlet.name! outl.brand = brand.id try! self.realm.write { self.realm.add(outl) } for override in outlet.override! { let overRide =

Hide Selected Cell from the Table - Swift4

夙愿已清 提交于 2019-12-11 06:26:43
问题 I have a list with 4 objects of places that I query from my Realm database. Optional(Results<Place> <0x7feaaea447c0> ( [0] Place { name = Daniel Webster Highway; country = United States; lat = 42.72073329999999; lon = -71.44301460000001; }, [1] Place { name = District Avenue; country = United States; lat = 42.48354969999999; lon = -71.2102486; }, [2] Place { name = Gorham Street; country = United States; lat = 42.62137479999999; lon = -71.30538779999999; }, [3] Place { name = Route de HHF;

Make a (deep) copy of an Object that conforms to Codable

匆匆过客 提交于 2019-12-11 06:17:56
问题 I have an object that subclasses Object from Realm, and conforms to Codable in order to convert to and from JSON when talking to an API. How can I make a deep copy (include children objects) by leveraging the Codable protocol? 回答1: This will make a deep copy of an object leveraging the Codable protocol. As mentioned by @itai-ferber it will have a high overhead when compared to NSCopying . class MyObject: Object, Codable { /* details omitted */ var children = List<ChildObject>() func copy()

How to keep Realm data in the same order as entered

∥☆過路亽.° 提交于 2019-12-11 06:09:26
问题 I have an application where I need to keep the data in the same order as it is entered. The data is entered into a List property. Everything works great until I have to delete an item. When the delete occurs the last item on the List takes the place of the one that was deleted. The UITableView shows the correct number of items but is not synchronized with the realm List. An example would be if I had data: 1, 2, 3, 4, 5, 6 I then delete: 3 The realm data looks like this: 1, 2, 6, 4, 5 The

Find schemaVersion of realm in swift 4.0

风流意气都作罢 提交于 2019-12-11 06:09:10
问题 I am relatively new in this field, and really stuck here as how to get the current schemaVersion of realm. I tried Below code to check my schemaVersion let configCheck = Realm.Configuration(); let configCheck2 = Realm.Configuration.defaultConfiguration; let schemaVersion = configCheck.schemaVersion print("Schema version \(schemaVersion) and configCheck2 \(configCheck2.schemaVersion)") but Output was coming zero always Schema version 0 and configCheck2 0 But I have already changed my