In javascript I am using this function
export async function createNewRealm(name) {
if (process.env.REALM_DISABLED === 'true') return Promise.resolve();
if (!connectionAdminUser) await establishRealmConnection();
console.log(`Creating ${name} at realms://${server}/${name}`);
return Realm.open({
sync: {
user: connectionAdminUser,
url: `realms://${server}/${name}`
}
});
}
Upon calling the function like this
let test = await realm.createNewRealm('test');
console.log(test);
console.log(test.empty);
I get following output
Creating test at realms://:SNIPPED/company-test
Connection[1]: Session[1]: client_reset_config = false, Realm exists = true, async open = false, client reset = false
Connection[1]: Connected to endpoint ':SNIPPED' (from ':SNIPPED')
Connection[1]: Disconnected
Realm {} <-- THIS being first console.log
true <-- THIS being second console.log
Connection[2]: Session[2]: client_reset_config = false, Realm exists = true, async open = false, client reset = false
Connection[2]: Connected to endpoint ':SNIPPED' (from ':SNIPPED')
Now I get that this is because test
in let test = await realm.createNewRealm('test');
is not proper javascript object, but proxy object.
What I would like to know - How can I inspect in code the content or at least see the keys via console.log?
The documentation here can be used, but I did notice that it is not always updated and I would like to avoid context switching by having to look every time if it is user.id
or user.identity
, etc...
So is there JS way to get those to output via console.log? I don't mind if it ends up being string, or array, just to be able to see the content of various realm objects on demand.
Also bonus question, in the log from realm itself I can see Realm exists = true
, but there is nothing in documentation saying if I can see that via object being returned. So far I am checking if it is new by calling test.empty
, is there an easier way? (related since this is the reason why I am asking main question)