realm-js
realm-js copied to clipboard
user.customData is not returning data in proper JSON format
How frequently does the bug occur?
All the time
Description
After login user.customData should return the data in proper json formats.
But receiving the data in E-JSON format.
See stats property:
{
"_id": "62efedca3587e6e83c0fc675",
"lastName": "",
"firstName": "Ahmad",
"email": "[email protected]",
"password": "",
"company": "",
"optNewsLetter": true,
"id": "62f013361798f5d543a7fa52",
"verified": true,
"acceptedTermsDate": "08/08/2022, 00:30:22",
"acStatus": null,
"acId": null,
"managedUsers": [],
"stats": {
"appStartCount": {
"$numberInt": "13"
},
"batchRunExportCount": {
"$numberInt": "1"
},
"testRunCount": {
"success": {
"$numberInt": "12"
},
"failed": {
"$numberInt": "2"
}
}
}
}
Expected: It should return data in proper json or should provide toArray() method like mongodb-nodejs package provides
Stacktrace & log output
No response
Can you reproduce the bug?
Yes, always
Reproduction Steps
const credentials = Realm.Credentials.emailPassword(params.email, params.password)
const user = await app.logIn(credentials)
console.log(user.customData)
Version
1.7.1
What SDK flavour are you using?
Atlas App Services (auth, functions, etc.)
Are you using encryption?
No, not using encryption
Platform OS and version(s)
MacOs
Build environment
Electron: ReactJS, NodeJs
Cocoapods version
No response
Thanks for reporting this. I believe we have the same issue in the Realm Web SDK.
@kraenhansen Any idea when it will be fixed?
We have the same issue in the Web SDK. I found a work around, but it's not awesome.
import { EJSON } from 'bson';
const appStartCount = EJSON.deserialize(user.customData.stats.appStartCount);
Custom user data can be a generic MongoDB document, and returning BSON data will capture all types.