realm

Open Realm-JS Defined in Another .JS File

一笑奈何 提交于 2019-12-08 05:01:02
问题 I am trying to use realm-js in react-native so what I did is created a class of realm-js in my action folder as in LoginActions.js , which will write the data after user logs in. My Question is How do I open the same schema into another .js file? Realm-js Defined in LoginActions.js: class Login { get token() { return this.token; } } Login.schema = { name: 'Login', primaryKey: 'id', properties: { id: 'int', token: 'string', } }; Then I Open the Realm to Write and Update in this Schema with

How to properly unit test Realm migration

荒凉一梦 提交于 2019-12-08 04:28:07
问题 I have looked at the post here How to unit test Realm migrations and am trying to implement what they have stated which is the following: Store old .realm files and write tests for before / after migrations. I have my v0.realm file in my unit test bundle and am creating a copy of it to work with. The issue is that with my latest migration I removed a Type from my application and thus from Realm and I'd like to test that it no longer exists. When I set up my realm configuration I should be

Asynchronous read / write to Realm using RXJava 2

喜欢而已 提交于 2019-12-08 04:05:29
问题 My first implementation of an asynchronous operation using RXJava 2 Goal: Get json data from the server with library Retrofit2 . If successful, then write the data to Realm and immediately after the record get the data back and send to the adapter of RecyclerView . So, I realized all this in this way: private void fetchChatsFromNetwork(int count, AccessDataModel accessDataModel) { String accessToken = accessDataModel.getAccessToken(); MyApplication.getRestApi().getChats(count, accessToken,

Is it possible to serialise a Realm Object into JSON?

情到浓时终转凉″ 提交于 2019-12-08 03:54:33
问题 Does anyone know if there's any support in Realm (iOS) to be able to serialise an RLMObject into JSON for export? 回答1: I don't believe there is any support officially, but this article may describe some other third party libraries which may be able to achieve what you are after http://blog.matthewcheok.com/working-with-realm/ 回答2: It should work like with any other objects: NSData *jsonData = [NSJSONSerialization dataWithJSONObject:realmObject options:NSJSONWritingPrettyPrinted error:

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**

io.realm.RealmObject not found

若如初见. 提交于 2019-12-08 02:01:52
问题 In my android library project, i install Realm as a Gradle plugin (as described in https://realm.io/docs/java/latest/). When I add my library project (aar file) into my application project, it can not build with error "cannot access RealmObject class file for io.realm.RealmObject not found" I have to install realm plugin in application project to overcome this error. Anyone can help me this situation, i do not want install realm plugin in application project. 回答1: i do not want install realm

Swift how to declare realm results?

烂漫一生 提交于 2019-12-08 01:47:27
问题 How to declare Results generic I want to declare it like global variable in UITableViewController and fill within viewDidLoad func Here's my code class ContactsController: UITableViewController { var contacts = Results<Contact>() override func viewDidLoad() { super.viewDidLoad() contacts = Domain.FetchContacts() } } But I get error Cannot invoke initializer for type 'Results' with no arguments How can I declare it? 回答1: I declared results generic like this var contacts: Results<Contact>? =

Convert from Realm Results to Array produce empty objects

心不动则不痛 提交于 2019-12-08 01:38:44
问题 When I try to convert from Results to Swift Array the properties are on the default values. So let's say I write a Request object like this: let realm = try! Realm() try! realm.write { realm.add(request, update: true) } Then when I'm reading them from Realm like this: let realm = try! Realm() let requestsFromRealm = realm.objects(Request.self) I got the results just fine. I need to convert the Results object to Array. I did it: let requests = Array(requestsFromRealm) The requests objects are

Realm object as member is nil after saving

夙愿已清 提交于 2019-12-08 00:11:54
问题 I'm facing an issue where a Realm object has another Realm object as member which is always nil after adding to the database. class MedPack: Object { dynamic var uuid = NSUUID().UUIDString dynamic var medicine: Medicine? convenience init(medicine: Medicine) { self.init() self.medicine = medicine } override static func primaryKey() -> String? { return "uuid" } } The reference to the object Medicine is always nil after adding. class Medicine: Object { var uuid = NSUUID().UUIDString var name:

Saving Nested Objects to Realm Database in .Net

南笙酒味 提交于 2019-12-07 21:19:14
问题 I'm new to realm and I'm having a lot of trouble getting a nested object to save. I can save the parent, but I get a Realms.Exceptions.RealmObjectManagedByAnotherRealmException saying Cannot start to manage an object with a realm when it's already managed by another realm . I only have one realm and I'm creating a new object! This is what the parent class looks like: public class Transaction : RealmObject { [PrimaryKey] public string ID { get; set; } = Guid.NewGuid().ToString(); ... public