Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Update method names #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ module.exports = function(config) {
* @returns {{get: get, save: save, all: all, allById: allById}}
*/
function getStorageObj(client, namespace) {
var delete = function(id, cb) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you mind changing this to a function declaration (function delete(id, cb) {...})? That avoids any possible problems introduced by hoisting.

client.hdel(namespace, [id], cb);
};
return {
get: function(id, cb) {
client.hget(namespace, id, function(err, res) {
Expand All @@ -48,8 +51,12 @@ function getStorageObj(client, namespace) {

client.hset(namespace, object.id, JSON.stringify(object), cb);
},
//remove is a non-standard name, but for compatbility included here
remove: function(id, cb) {
client.hdel(namespace, [id], cb);
return delete(id, cb);
},
delete: function(id, cb) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind covering this new method with tests? You can just copy the tests for remove and rename the describe and method call, since these should behave identically.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return delete(id, cb);
},
all: function(cb, options) {
client.hgetall(namespace, function(err, res) {
Expand Down