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