Skip to content

Instantly share code, notes, and snippets.

@puppycodes
Created January 24, 2019 22:22
Show Gist options
  • Save puppycodes/b5935d41b89d63e6bfbef2e01963e698 to your computer and use it in GitHub Desktop.
Save puppycodes/b5935d41b89d63e6bfbef2e01963e698 to your computer and use it in GitHub Desktop.
exports = function(payload, response) {
const mongodb = context.services.get('<your-service-name>');
const collection = mongodb.db("<your-db-name>").collection("<your-collection-name>");
var json = EJSON.parse(payload.body.text());
var user = json.userId;
var status = json.orderStatus;
return collection
.updateOne(
{"body.userId": user},
{$set:
{
"body": json,
"query": payload.query
}
},
{upsert: true}
)
.then(result => {
// result.matchedCount === 1;
return result;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment