Skip to content

Instantly share code, notes, and snippets.

@ashleygwilliams
Created June 18, 2015 16:37
Show Gist options
  • Save ashleygwilliams/3eab77527f3daf423b4c to your computer and use it in GitHub Desktop.
Save ashleygwilliams/3eab77527f3daf423b4c to your computer and use it in GitHub Desktop.
43 BaseController.prototype.update = function(req, reply) {
44 var result = this.Model.query({
45 where: {
46 id: req.params.id
47 }
48 })
49 .save(this.data(req), {
50 method: 'update',
51 patch: 'true',
52 require: 'true'
53 })
54 .call('fetch')
55 .then(function(record) {
56 if (!record) { throw Boom.notFound(); }
57 return req.generateResponse(record.toJSON())
58 .code(201);
59 })
60 .catch(function(e){
61 return Boom.create(500, 'No Rows Updated');
62 })
63 return reply(result);
64 };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment