Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add update function #37

Open
wants to merge 1 commit into from

2 participants

@MichaelVdheeren

The current implementation has no update function

@cbshakumar

Can someone please merge this in? I would really like to see this functionality in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 16, 2013
  1. @MichaelVdheeren

    Added update function

    MichaelVdheeren authored
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 0 deletions.
  1. +18 −0 nstore.js
View
18 nstore.js
@@ -130,6 +130,24 @@ var nStore = module.exports = Pattern.extend({
});
this.checkQueue();
},
+
+ update: function update(key, attr, callback) {
+ var self = this;
+ Step(
+ function() {
+ self.get(key, this);
+ },
+ function(err, doc, key) {
+ if (err) throw err;
+
+ for (attrKey in attr) {
+ doc[attrKey] = attr[attrKey];
+ }
+
+ self.save(key, doc, callback)
+ }
+ );
+ }
// Load a single record from the disk
get: function getByKey(key, callback) {
Something went wrong with that request. Please try again.