Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework missed helper #5

Open
chapel opened this issue Apr 25, 2012 · 0 comments
Open

Rework missed helper #5

chapel opened this issue Apr 25, 2012 · 0 comments

Comments

@chapel
Copy link
Owner

chapel commented Apr 25, 2012

After some testing and using the existing implementation, I have found it to be inadequate and not very intuitive. Requiring more code to do something fairly simple, multiple loops at times.

Instead of an object or an array, it will simply be an object like so:

missed = {
    keys: [
        'key'
      , 'key2'
    ]
  , save: function(key, value) {
      // Save value to appropriate key
    }
}

This would allow usage like so:

db.find(missed.keys, function(err, values) {
  if (err) return done(err)

  for (var i = 0; i < values.length; i+=1) {
    missed.save(values[i].key, values[i])
  }

  done()
}

I could even get rid of done, and have missed.done(), but I think having a clear done() function makes more sense in Node.js conventions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant