Hi @stoplion,
Attaching the code snippet below:
const { MongoClient } = require("mongodb");
exports.onExecutePostUserRegistration = async (event) => {
const newUser = { sub: event.user.sub };
const client = await MongoClient.connect(event.secrets.MONGO_DB);
const db = client.db();
await db.collection("users").insertOne(newUser);
client.close();
};
The URL value of the event.secrets.MONGO_DB
should be your MongoDB URL, which should be in the format:
mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]
For example:
mongodb://mongodb0.example.com:27017
Reference: https://www.mongodb.com/docs/manual/reference/connection-string/
I hope this helps!
Please let me know if I can do anything else to help.
Thanks,
Rueben