Created
March 3, 2019 11:46
-
-
Save mrlynn/16a9ed0e1cb0fc98374816dfa79b4365 to your computer and use it in GitHub Desktop.
Receive POST from Google Sheets and Insert into MongoDB Database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports = async function(payload) { | |
const mongodb = context.services.get("mongodb-atlas"); | |
const eventsdb = mongodb.db("events"); | |
const eventscoll = eventsdb.collection("events"); | |
const result= await eventscoll.insertOne(payload.query); | |
var id = result.insertedId.toString(); | |
if(result) { | |
return JSON.stringify(id,false,false); | |
} | |
return { text: `Error saving` }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment