MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Stitch: Can't make custom user data to appear in userObject.customData

Hi!
I followed steps in stitch documentation:
Cutom User Data

  1. In the Users section of Mongo Stitch panel I enabled custom data. I chose database, collection ( users ) and stated User ID Field to be userId . Then I deployed changes.
    CustomUserData

  2. I have a created and confirmed user.

  3. I copied the user’s id and inserted the following document to the users collection db.users.insertOne({userId: ObjectId('copied_id'), description: "something"}).

  4. The document exists and I can see it when querying the collection. The userId field has correct ObjectId() value (in the correct ObjectId format).

Nonetheless, when I log in with the user (I log in via Node.js SDK) the customData property of the userObject is empty. It should contain at least the description field.

What can be the reason? Has anyone had a similar problem?
Cheers,
Eryk

+1 having this problem too. I’ve reached out to support and will post their reply here also.

Hi Folks – Sorry to hear that you’re having trouble accessing custom user data within Stitch. After scanning the documentation looks like there might be a typo in the sample code, we believe –

const speaksEnglish = user.profile.customData.primaryLanguage === "English";

Should be –

const speaksEnglish = user.customData.primaryLanguage === "English";

We’ve filed a ticket to update our documentation. If that doesn’t resolve your issue, would you mind either posting or sending me directly an example document from your users collection (with any PII removed).

same issue here… pebcak :confused:

I fixed it by setting userId as String, not ObjectId.
(not seen in doc btw)

Hoping it’s not too late :wink: