Get Object Returns Realm Object Instead of Class Instance
See original GitHub issueI have a model like this, to be able to store details
field as JSON
class Person {
set details(data) { this._details = data ? JSON.stringify(data) : null; }
get details() { return this._details ? JSON.parse(this._details) : null; }
}
Person.schema = {
name: 'Person',
primaryKey: 'id',
properties: {
id: 'string',
name: 'string',
_details: { type: 'string', optional: true }
}
};
Now when I do
realm.write(() => {
// this is a write block for some other objects, but at some point I need to find a person
let person = realm.objectForPrimaryKey('Person', id);
console.log(person);
});
It will log out an instance of RealmObject
with getters and setters for _details
but nothing for details
, so its not an instance of Person
, am I missing something here?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Realm Query in React Native Returns Realm Object Instead of ...
It will log out an instance of RealmObject with getters and setters for _details but nothing for details , so its not an...
Read more >Object Class Reference - MongoDB
Object is a class used to define Realm model objects. In Realm you define your model classes by subclassing Object and adding properties...
Read more >Factory.Realm - IBM
Retrieves an object of the Realm class by the specified connection and symbolic name. This method always makes a round-trip to the server....
Read more >instanceof - JavaScript - MDN Web Docs
// This class allows plain objects to be disguised as this class's instance, // as long as the object has a particular flag...
Read more >Class Realm
This method modifies the object in-place, meaning that after it has run, ... the returned object will be an instance of a user-defined...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I made that working by doing something like
And then in the class definition
I just use
eventType.toJSON()
and I get@alexsotocx how to check the types for int?[ ] or string?[ ] …