In a multi process environment, like an electron app, it would be valuable to be able to pass users between processes in a serialized form.
I would expect that when logging in to ROS and serializing the resulting user I would get an object as follows:
Realm.Sync.User.register("http://localhost:9080", username, password, (err, user) => {
const userString = JSON.stringify(user);
// user === "{token: "...", identity: "some-username", server: "http://localhost:9080", isAdmin: false }"
This could be fixed by implementing a toJSON method on the Realm.Sync.User class: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior
In addition to this, it would be valuable to create a Realm.Sync.User from a JSON representation. This could be implemented with a fromJSON method on the user.
Serializing a Realm.Sync.User (JSON.stringify(user)) gives you the string representation of an empty object ({}) and the fields of a User are all implemented as getters that cannot be set.
JSON.stringify(user)See "Expected Results"
2.0.0-rc5a toJSON in realm objects and collections would be great. Useful for debugging and serialization support.
Most helpful comment
a toJSON in realm objects and collections would be great. Useful for debugging and serialization support.