Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // creates a new facility for a location
- app.post('/v.1/locations/:location_id/facilities', function(req, res){
- // add the location id to the json
- var facility = req.body;
- facility['location'] = req.params.location_id;
- require('mongodb').connect(mongourl, function(err, conn){
- conn.collection('facilities', function(err, coll){
- coll.insert( facility, {safe:true}, function(err){
- res.writeHead(200, {
- "Content-Type": "application/json",
- "Access-Control-Allow-Origin": "*"
- });
- res.end(JSON.stringify(facility));
- });
- });
- });
- });
Add Comment
Please, Sign In to add comment