I am trying to run funciton once user is created .I am creating user with Appservices UI and in user settings enabled Custom User Data and wrote function there which is below one for testing purpose but my custom_user collection is not updating even after user created .
import { v4 as uuidv4 } from 'uuid';
exports = async function (user) {
const customUserDataCollection = context.services
.get("mongodb-atlas")
.db("myapp")
.collection("custom_user");
try {
await customUserDataCollection.insertOne({
// Save the user's account ID to your configured user_id_field
user_id: user.id,
name: "Swaminathan"
});
return customUserDataCollection.find({user_id:user.id});
} catch (e) {
console.error(`Failed to create custom user data document for user:${user.id}`);
throw e
}
}