Throw error on PUT without id.

This commit is contained in:
DallonF
2012-06-29 09:27:40 -07:00
parent 361face4fd
commit 2b035c3dae

View File

@@ -130,7 +130,7 @@ Collection.prototype.sanitize = function (body) {
Collection.prototype.handle = function (ctx) {
// set id one wasnt provided in the query
ctx.query.id = ctx.query.id || this.parseId(ctx);
ctx.query.id = ctx.query.id || this.parseId(ctx) || (ctx.body && ctx.body.id);
if (ctx.req.internal) {
ctx.session.internal = true;
@@ -140,8 +140,12 @@ Collection.prototype.handle = function (ctx) {
case 'GET':
this.find(ctx.session, ctx.query, ctx.dpd, ctx.done);
break;
case 'POST':
case 'PUT':
if (!ctx.query.id) {
ctx.done("must provide id to update an object");
break;
}
case 'POST':
this.save(ctx.session, ctx.body, ctx.query, ctx.dpd, ctx.done);
break;
case 'DELETE':