Last active
December 13, 2015 19:29
-
-
Save travispbrown/4963191 to your computer and use it in GitHub Desktop.
Short example of node.js Express method to POST resource data into MongoDB. This was just a snippet for my blog to illustrate the simplicity of using MongoDB. Assume the data has already been validated, and MongoDB connection established.
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
resource.post (req, res) -> | |
collection.insert req.body, safe:true, (error, data) -> | |
if !error? | |
res.end 201 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment