Skip to content

Commit

Permalink
FIX lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
janantala committed May 7, 2015
1 parent 45bdd90 commit 1c00674
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions lib/services/server/mongodbDeviceRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,26 @@ function getByName(deviceName, callback) {
}

/**
* Inserts the given object in the registry and removes the old registration. The generated ID is returned through the callback.
* Removes the object identified by this id from the registry. The removed object is passed as the first callback
* parameter.
*
* @param {Integer} id Identifier of the object to be removed.
*/
function unregister(id, callback) {
Device.model.findOneAndRemove({ id: id }, function(error, device) {
if (error) {
callback(errors.InternalDbError(error));
} else if (device) {
callback(null, device.toObject());
} else {
callback(new errors.DeviceNotFound(id));
}
});
}

/**
* Inserts the given object in the registry and removes the old registration.
* The generated ID is returned through the callback.
*
* @param {Object} object Object to insert into the registry.
*/
Expand Down Expand Up @@ -118,32 +137,14 @@ function register(object, callback) {
if (!error && result) {
unregister(result.id, function(err){
return mongoStore(saveDeviceHandler);
})
});
}
else {
return mongoStore(saveDeviceHandler);
}
});
}

/**
* Removes the object identified by this id from the registry. The removed object is passed as the first callback
* parameter.
*
* @param {Integer} id Identifier of the object to be removed.
*/
function unregister(id, callback) {
Device.model.findOneAndRemove({ id: id }, function(error, device) {
if (error) {
callback(errors.InternalDbError(error));
} else if (device) {
callback(null, device.toObject());
} else {
callback(new errors.DeviceNotFound(id));
}
});
}

/**
* Remove all the objects from the registry.
*/
Expand Down

0 comments on commit 1c00674

Please sign in to comment.