Guest User

Untitled

a guest
Sep 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. // creates a new facility for a location
  2. app.post('/v.1/locations/:location_id/facilities', function(req, res){
  3.  
  4. // add the location id to the json
  5. var facility = req.body;
  6. facility['location'] = req.params.location_id;
  7.  
  8. require('mongodb').connect(mongourl, function(err, conn){
  9. conn.collection('facilities', function(err, coll){
  10. coll.insert( facility, {safe:true}, function(err){
  11. res.writeHead(200, {
  12. "Content-Type": "application/json",
  13. "Access-Control-Allow-Origin": "*"
  14. });
  15. res.end(JSON.stringify(facility));
  16. });
  17. });
  18. });
  19.  
  20. });
Add Comment
Please, Sign In to add comment