Merge pull request #7 from strongloop/SLA-422
Mark id arguments to be required
This commit is contained in:
commit
84a40cc1c6
12
lib/dao.js
12
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'}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue