pixl-server-storage 3.1.13 → 3.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/API.md CHANGED
@@ -17,6 +17,7 @@ var storage = server.Storage;
17
17
  * [putStream](#putstream)
18
18
  * [get](#get)
19
19
  * [getMulti](#getmulti)
20
+ * [getBuffer](#getbuffer)
20
21
  * [getStream](#getstream)
21
22
  * [getStreamRange](#getstreamrange)
22
23
  * [head](#head)
@@ -60,6 +61,8 @@ var storage = server.Storage;
60
61
  * [hashPutMulti](#hashputmulti)
61
62
  * [hashGet](#hashget)
62
63
  * [hashGetMulti](#hashgetmulti)
64
+ * [hashUpdate](#hashupdate)
65
+ * [hashUpdateMulti](#hashupdatemulti)
63
66
  * [hashEach](#hasheach)
64
67
  * [hashEachSync](#hasheachsync)
65
68
  * [hashEachPage](#hasheachpage)
@@ -1012,6 +1015,28 @@ storage.hashUpdate( 'users', 'bsanders', { age: 81 }, function(err) {
1012
1015
 
1013
1016
  This would update Bernie's age to 81 without affecting any of the other properties in his user record.
1014
1017
 
1018
+ ## hashUpdateMulti
1019
+
1020
+ ```javascript
1021
+ storage.hashUpdateMulti( PATH, RECORDS, CALLBACK );
1022
+ ```
1023
+
1024
+ The `hashUpdateMulti()` method updates multiple key/value pairs in a hash. The `PATH` specifies the main storage path of the hash, and `RECORDS` should be an object containing all the keys and values you want to update. See [hashUpdate()](#hashupdate) for details on the update format.
1025
+
1026
+ ```js
1027
+ var updates = {
1028
+ "bsanders": { age: 81 },
1029
+ "hclinton": { age: 75 },
1030
+ "dtrump": { age: 77 }
1031
+ };
1032
+
1033
+ storage.hashUpdateMulti( 'users', records, function(err) {
1034
+ if (err) throw err;
1035
+ } );
1036
+ ```
1037
+
1038
+ This would update the `age` properties in each record, without affecting the other data.
1039
+
1015
1040
  ## hashEach
1016
1041
 
1017
1042
  ```javascript
@@ -199,8 +199,9 @@ When transactions are enabled, many compound storage methods (those that execute
199
199
  - **Hash Methods**
200
200
  - [hashCreate()](API.md#hashcreate)
201
201
  - [hashPut()](API.md#hashput)
202
- - [hashUpdate()](API.md#hashupdate)
203
202
  - [hashPutMulti()](API.md#hashputmulti)
203
+ - [hashUpdate()](API.md#hashupdate)
204
+ - [hashUpdateMulti()](API.md#hashupdatemulti)
204
205
  - [hashCopy()](API.md#hashcopy)
205
206
  - [hashRename()](API.md#hashrename)
206
207
  - [hashDeleteMulti()](API.md#hashdeletemulti)
package/hash.js CHANGED
@@ -426,6 +426,25 @@ module.exports = Class.create({
426
426
  }); // get
427
427
  },
428
428
 
429
+ hashUpdateMulti: function(path, records, callback) {
430
+ // update multiple hash records at once, given object of keys and values
431
+ // need concurrency limit of 1 because hashUpdate locks
432
+ var self = this;
433
+
434
+ async.eachLimit(Object.keys(records), 1,
435
+ function(hkey, callback) {
436
+ // iterator for each key
437
+ self.hashUpdate(path, hkey, records[hkey], function(err) {
438
+ callback(err);
439
+ } );
440
+ },
441
+ function(err) {
442
+ // all keys updated
443
+ callback(err);
444
+ }
445
+ );
446
+ },
447
+
429
448
  hashEachPage: function(path, iterator, callback) {
430
449
  // call user iterator for each populated hash page, data only
431
450
  // iterator will be passed page items hash object
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixl-server-storage",
3
- "version": "3.1.13",
3
+ "version": "3.1.14",
4
4
  "description": "A key/value/list storage component for the pixl-server framework.",
5
5
  "author": "Joseph Huckaby <jhuckaby@gmail.com>",
6
6
  "homepage": "https://github.com/jhuckaby/pixl-server-storage",
package/transaction.js CHANGED
@@ -454,8 +454,9 @@ module.exports = Class.create({
454
454
  'listEachPageUpdate',
455
455
  'hashCreate',
456
456
  'hashPut',
457
+ 'hashPutMulti',
457
458
  'hashUpdate',
458
- 'hashPutMulti',
459
+ 'hashUpdateMulti',
459
460
  'hashCopy',
460
461
  'hashRename',
461
462
  'hashDeleteMulti',