How to add users to mongoDB when new user's sign in

what is the best way to push data into our database when a user is created in auth0.
There is something called post registration hook in auth0 pipelines , post registration actions and there is SSO integration for mongo db .
Not sure what to use , Would be useful If you provide some sample code on how It’s done , because I not sure how the inline auth0 editor is connecting to the our database

In case anyone is finding this recently - here is a working snippet. Add this to an Action in Auth0 as described here: Write Your First Action

 * @param {Event} event - Details about newly created user.

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);

The user registration process will create an entry in your MongoDB database.