Skip to content

Commit

Permalink
Deployment from App Services
Browse files Browse the repository at this point in the history
  • Loading branch information
mongodb-atlas-app-services[bot] authored Jun 21, 2024
1 parent 9b341fe commit 275225a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app-1/auth/custom_user_data.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"enabled": false
"enabled": true,
"mongo_service_name": "mongodb-atlas",
"database_name": "db",
"collection_name": "Database",
"user_id_field": "Clusters",
"on_user_creation_function_name": "onUserCreation"
}
4 changes: 4 additions & 0 deletions app-1/functions/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
{
"name": "resetFunc",
"private": true
},
{
"name": "onUserCreation",
"private": false
}
]
19 changes: 19 additions & 0 deletions app-1/functions/onUserCreation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
This function will run after a user is created and is called with an object representing that user.
This function runs as a System user and has full access to Services, Functions, and MongoDB Data.
Example below:
exports = (user) => {
// use collection that Custom User Data is configured on
const collection = context.services.get("<SERVICE_NAME>").db("<DB_NAME>").collection("<COLL_NAME>");
// insert custom data into collection, using the user id field that Custom User Data is configured on
const doc = collection.insertOne({ <USER_ID_FIELD>: user.id, name: user.data.name });
};
*/

exports = (user) => {
return;
};
1 change: 1 addition & 0 deletions app-1/functions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"dependencies":{"Npm":"3.0.0"}}

0 comments on commit 275225a

Please sign in to comment.