Unlock seamless workflows and faster delivery with our latest releases – get the details

MongoDB migration to serverless Atlas/Realm and seeking advice on serverless functions and database migration.

9 replies
Last updated: Jun 12, 2023
Hello everybody! Hope you are doing well.

exports.createAtlasUserWithEmail = async function(email) {

const realmApp = context.services.get('mongodb-atlas');

const usersCollection = realmApp.db('db-name.db').collection('User');


// Find the document with the specified email address

const user = await usersCollection.findOne({ username: email });


if (user) {

try {

// Create an Atlas user using the email address

const atlasUser = await realmApp.emailPasswordAuth.registerUser({ email, password: 'testtest' });


// Return the created Atlas user

return atlasUser;

} catch (error) {
`throw new Error(
Error creating Atlas user: ${error.message}
);`
}

} else {
`throw new Error(
User not found with the specified email address: ${email}
);`
}

};

I'm looking for some advice & consultation on a MongoDB migration we're doing to serverless MongoDB with Atlas/Realm.

At the moment we're trying to understand serverless functions inside of Atlas for CRUD and User Auth/Setup/Delete/etc

Next we'll be looking at database migration and other more complicated functions.

Please apply if you have specific experience working with
https://realm.mongodb.com
Jun 12, 2023, 4:45 PM
are you migrating from mongo to sanity.io ?
Jun 12, 2023, 5:07 PM
I think no.
Jun 12, 2023, 5:08 PM
ok so what does this question have to do with sanity being that this is a sanity slack?
Jun 12, 2023, 5:08 PM
I believe the people in this slack, have rich experience with several techniques not only sanity,
Jun 12, 2023, 5:10 PM
Could you help me?
Jun 12, 2023, 5:10 PM
no maybe you should post this in random since it has nothing to do with sanity
Jun 12, 2023, 5:11 PM
As I mentioned in your other thread, this is not an appropriate place to look for this sort of help.
Jun 12, 2023, 6:48 PM
yes, I will remember.Sorry again.
Jun 12, 2023, 6:48 PM
Many thanks!
Jun 12, 2023, 6:49 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?