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) {
|
DataAccessObject.exists = function exists(id, cb) {
|
||||||
if (stillConnecting(this.dataSource, this, arguments)) return;
|
if (stillConnecting(this.dataSource, this, arguments)) return;
|
||||||
|
|
||||||
if (id) {
|
if (id !== undefined && id !== null && id !== '') {
|
||||||
this.dataSource.connector.exists(this.modelName, id, cb);
|
this.dataSource.connector.exists(this.modelName, id, cb);
|
||||||
} else {
|
} else {
|
||||||
cb(new Error('Model::exists requires positive id argument'));
|
cb(new Error('Model::exists requires the id argument'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// exists ~ remoting attributes
|
// exists ~ remoting attributes
|
||||||
setRemoting(DataAccessObject.exists, {
|
setRemoting(DataAccessObject.exists, {
|
||||||
description: 'Check whether a model instance exists in the data source',
|
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'},
|
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
|
// find ~ remoting attributes
|
||||||
setRemoting(DataAccessObject.findById, {
|
setRemoting(DataAccessObject.findById, {
|
||||||
description: 'Find a model instance by id from the data source',
|
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},
|
returns: {arg: 'data', type: 'any', root: true},
|
||||||
http: {verb: 'get', path: '/:id'}
|
http: {verb: 'get', path: '/:id'}
|
||||||
});
|
});
|
||||||
|
@ -530,7 +530,7 @@ DataAccessObject.deleteById =
|
||||||
// deleteById ~ remoting attributes
|
// deleteById ~ remoting attributes
|
||||||
setRemoting(DataAccessObject.deleteById, {
|
setRemoting(DataAccessObject.deleteById, {
|
||||||
description: 'Delete a model instance by id from the data source',
|
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'}
|
http: {verb: 'del', path: '/:id'}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue