mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Match devicestatus api indention
This commit is contained in:
@@ -56,42 +56,42 @@ function configure (app, wares, ctx) {
|
||||
* endpoint uses same search logic to remove records from the database.
|
||||
*/
|
||||
function delete_records(req, res, next) {
|
||||
var query = req.query;
|
||||
if (!query.count) {
|
||||
query.count = 10
|
||||
var query = req.query;
|
||||
if (!query.count) {
|
||||
query.count = 10
|
||||
}
|
||||
|
||||
console.log('Delete records with query: ', query);
|
||||
|
||||
// remove using the query
|
||||
ctx.devicestatus.remove(query, function(err, stat) {
|
||||
if (err) {
|
||||
console.log('devicestatus delete error: ', err);
|
||||
return next(err);
|
||||
}
|
||||
// yield some information about success of operation
|
||||
res.json(stat);
|
||||
|
||||
console.log('Delete records with query: ', query);
|
||||
console.log('devicestatus records deleted');
|
||||
|
||||
// remove using the query
|
||||
ctx.devicestatus.remove(query, function(err, stat) {
|
||||
if (err) {
|
||||
console.log('devicestatus delete error: ', err);
|
||||
return next(err);
|
||||
}
|
||||
// yield some information about success of operation
|
||||
res.json(stat);
|
||||
|
||||
console.log('devicestatus records deleted');
|
||||
|
||||
return next();
|
||||
});
|
||||
return next();
|
||||
});
|
||||
}
|
||||
|
||||
api.delete('/devicestatus/:id', ctx.authorization.isPermitted('api:devicestatus:delete'), function(req, res, next) {
|
||||
if (!req.query.find) {
|
||||
req.query.find = {
|
||||
_id: req.params.id
|
||||
};
|
||||
} else {
|
||||
req.query.find._id = req.params.id;
|
||||
}
|
||||
if (!req.query.find) {
|
||||
req.query.find = {
|
||||
_id: req.params.id
|
||||
};
|
||||
} else {
|
||||
req.query.find._id = req.params.id;
|
||||
}
|
||||
|
||||
if (req.query.find._id === '*') {
|
||||
// match any record id
|
||||
delete req.query.find._id;
|
||||
}
|
||||
next();
|
||||
if (req.query.find._id === '*') {
|
||||
// match any record id
|
||||
delete req.query.find._id;
|
||||
}
|
||||
next();
|
||||
}, delete_records);
|
||||
|
||||
// delete record that match query
|
||||
|
||||
Reference in New Issue
Block a user