diff --git a/lib/dao.js b/lib/dao.js index c018fe57..e7d08012 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -296,19 +296,19 @@ DataAccessObject.findOrCreate = function findOrCreate(query, data, callback) { DataAccessObject.exists = function exists(id, cb) { if (stillConnecting(this.dataSource, this, arguments)) return; - if (id) { + if (id !== undefined && id !== null && id !== '') { this.dataSource.connector.exists(this.modelName, id, cb); } else { - cb(new Error('Model::exists requires positive id argument')); + cb(new Error('Model::exists requires the id argument')); } }; // exists ~ remoting attributes setRemoting(DataAccessObject.exists, { description: 'Check whether a model instance exists in the data source', - accepts: {arg: 'id', type: 'any', description: 'Model id'}, + accepts: {arg: 'id', type: 'any', description: 'Model id', required: true}, returns: {arg: 'exists', type: 'any'}, - http: {verb: 'get', path: '/exists'} + http: {verb: 'get', path: '/:id/exists'} }); /** @@ -336,7 +336,7 @@ DataAccessObject.findById = function find(id, cb) { // find ~ remoting attributes setRemoting(DataAccessObject.findById, { description: 'Find a model instance by id from the data source', - accepts: {arg: 'id', type: 'any', description: 'Model id'}, + accepts: {arg: 'id', type: 'any', description: 'Model id', required: true}, returns: {arg: 'data', type: 'any', root: true}, http: {verb: 'get', path: '/:id'} }); @@ -530,7 +530,7 @@ DataAccessObject.deleteById = // deleteById ~ remoting attributes setRemoting(DataAccessObject.deleteById, { description: 'Delete a model instance by id from the data source', - accepts: {arg: 'id', type: 'any', description: 'Model id'}, + accepts: {arg: 'id', type: 'any', description: 'Model id', required: true}, http: {verb: 'del', path: '/:id'} });