I am currently trying to read custom user data within my Realm application but have been unable to display any of the custom data linked to my atlas collection. Following the documentation, I enabled custom user data in my Users collection and set the user id field to ‘realmId’, a field name (string) that exists on every user document in the Users collection.
In my application, I am able to login in with email/password auth and then log the user’s id with ‘user.id’ as discussed in the accessing custom user data documentation. The documentation notes that the user object has the following fields: id, type, custom_data, data, and identities. Attempts to log the custom_data, type, and data fields returns undefined whereas I get expected results with user.id and user.identities.
Based on the documentation I would have expected to be able to view the users custom_data in the console. Is there a step that I am missing here?
Hey Jason, how are you writing to the the custom user data in your collection?
Were you able to cross check that a) that collection has metadata where realmId = the user id that you tried to access via SDK?
Does that collection have rules that let you read/write to it?
1 Like
Hey Sumedha, thanks for responding, I was actually able to resolve this recently. The key issue driving my problem was that the documentation may have a typo… it appears that custom user data is available through ‘user.customData.fieldName’ whereas the documentation is implying we should use ‘user.custom_data.fieldName’. I am using React Native.
Below is a link to at least one page that I am referring to:
If this is a typo or something that needs to be updated I am happy to submit a form or do anything on my end if it helps.
While the bottom of the page shows how to read Custom User Data from the SDK, I did bring this up to our docs team to surface it in a clearer way. Thanks for the feedback!