Created
January 24, 2019 22:22
-
-
Save puppycodes/b5935d41b89d63e6bfbef2e01963e698 to your computer and use it in GitHub Desktop.
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 = 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