Skip to content

Instantly share code, notes, and snippets.

@Suave
Created December 4, 2015 07:28
Show Gist options
  • Save Suave/6958281166034a9033ac to your computer and use it in GitHub Desktop.
Save Suave/6958281166034a9033ac to your computer and use it in GitHub Desktop.
var newShop = new Shop.model({
"name": body.name,
"type": body.shop_type,
"context": body.context
});
newShop.save()
.then(function(shop){
return this.body = {retcode:0};
})
.catch(function(err){
console.log("catch: " + err);
//next({retcode: 1, message: err.errors});
res.send(400, err);
return this.body = {retcode: 1, message: err.errors};
});
@hustKiwi
Copy link

hustKiwi commented Dec 4, 2015

function (req, res, next) {
   newShop.save()
    .then(function(shop){
        res.jsonp({retcode:0});
    })
    .catch(function(err){
        res.jsonp({retcode: 1, message: err.errors});
    });
}

@Suave
Copy link
Author

Suave commented Dec 4, 2015

exports.create = function*(req, res, next){

var body = this.request.body;


var newShop = new Shop.model({
    "name": body.name,
    "type": body.shop_type,
    "context": body.context
});

newShop.save()
.then(function(shop){
    res.jsonp({retcode:0});
})
.catch(function(err){
    console.log("catch:    " + err);
    //next({retcode: 1, message: err.errors});
    res.send(400, err);
    res.jsonp({retcode: 1, message: err.errors});
});     

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment