Skip to content

Instantly share code, notes, and snippets.

@mrlynn
Created March 3, 2019 11:46
Show Gist options
  • Save mrlynn/16a9ed0e1cb0fc98374816dfa79b4365 to your computer and use it in GitHub Desktop.
Save mrlynn/16a9ed0e1cb0fc98374816dfa79b4365 to your computer and use it in GitHub Desktop.
Receive POST from Google Sheets and Insert into MongoDB Database
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