mongodb 2.1.0-alpha → 2.1.2

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.
Files changed (63) hide show
  1. package/HISTORY.md +574 -429
  2. package/Makefile +2 -5
  3. package/README.md +108 -15
  4. package/conf.json +17 -13
  5. package/index.js +13 -2
  6. package/lib/admin.js +113 -47
  7. package/lib/aggregation_cursor.js +56 -28
  8. package/lib/apm.js +608 -0
  9. package/lib/bulk/common.js +7 -7
  10. package/lib/bulk/ordered.js +56 -17
  11. package/lib/bulk/unordered.js +52 -14
  12. package/lib/collection.js +671 -212
  13. package/lib/command_cursor.js +60 -32
  14. package/lib/cursor.js +313 -115
  15. package/lib/db.js +264 -105
  16. package/lib/gridfs/chunk.js +26 -29
  17. package/lib/gridfs/grid_store.js +150 -64
  18. package/lib/gridfs-stream/download.js +310 -0
  19. package/lib/gridfs-stream/index.js +335 -0
  20. package/lib/gridfs-stream/upload.js +450 -0
  21. package/lib/metadata.js +64 -0
  22. package/lib/mongo_client.js +69 -39
  23. package/lib/mongos.js +65 -20
  24. package/lib/replset.js +69 -34
  25. package/lib/server.js +35 -1
  26. package/lib/topology_base.js +22 -10
  27. package/lib/url_parser.js +111 -13
  28. package/lib/utils.js +9 -8
  29. package/mongolabs.js +427 -0
  30. package/package.json +8 -6
  31. package/t.js +68 -51
  32. package/test.js +12 -0
  33. package/test_boot/boot.sh +3 -0
  34. package/test_boot/ca.pem +49 -0
  35. package/test_boot/client.pem +48 -0
  36. package/test_boot/client_password.pem +51 -0
  37. package/test_boot/connect.js +29 -0
  38. package/test_boot/data/WiredTiger +2 -0
  39. package/test_boot/data/WiredTiger.lock +1 -0
  40. package/test_boot/data/WiredTiger.turtle +6 -0
  41. package/test_boot/data/WiredTiger.wt +0 -0
  42. package/test_boot/data/WiredTigerLAS.wt +0 -0
  43. package/test_boot/data/_mdb_catalog.wt +0 -0
  44. package/test_boot/data/collection-0-757073248613337118.wt +0 -0
  45. package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-44-37Z-00000 +0 -0
  46. package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-45-15Z-00000 +0 -0
  47. package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-46-31Z-00000 +0 -0
  48. package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-47-25Z-00000 +0 -0
  49. package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-49-07Z-00000 +0 -0
  50. package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-50-41Z-00000 +0 -0
  51. package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-50-53Z-00000 +0 -0
  52. package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-52-31Z-00000 +0 -0
  53. package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-54-53Z-00000 +0 -0
  54. package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-55-09Z-00000 +0 -0
  55. package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-55-38Z-00000 +0 -0
  56. package/test_boot/data/index-1-757073248613337118.wt +0 -0
  57. package/test_boot/data/mongod.lock +0 -0
  58. package/test_boot/data/sizeStorer.wt +0 -0
  59. package/test_boot/data/storage.bson +0 -0
  60. package/test_boot/server_password.pem +51 -0
  61. package/.travis.yml +0 -10
  62. package/t1.js +0 -59
  63. package/wercker.yml +0 -19
@@ -32,11 +32,12 @@ var Chunk = function(file, mongoObject, writeConcern) {
32
32
  if(mongoObjectFinal.data == null) {
33
33
  } else if(typeof mongoObjectFinal.data == "string") {
34
34
  var buffer = new Buffer(mongoObjectFinal.data.length);
35
- buffer.write(mongoObjectFinal.data, 'binary', 0);
35
+ buffer.write(mongoObjectFinal.data, 0, mongoObjectFinal.data.length, 'binary');
36
36
  this.data = new Binary(buffer);
37
37
  } else if(Array.isArray(mongoObjectFinal.data)) {
38
38
  var buffer = new Buffer(mongoObjectFinal.data.length);
39
- buffer.write(mongoObjectFinal.data.join(''), 'binary', 0);
39
+ var data = mongoObjectFinal.data.join('');
40
+ buffer.write(data, 0, data.length, 'binary');
40
41
  this.data = new Binary(buffer);
41
42
  } else if(mongoObjectFinal.data._bsontype === 'Binary') {
42
43
  this.data = mongoObjectFinal.data;
@@ -44,7 +45,7 @@ var Chunk = function(file, mongoObject, writeConcern) {
44
45
  } else {
45
46
  throw Error("Illegal chunk format");
46
47
  }
47
-
48
+
48
49
  // Update position
49
50
  this.internalPosition = 0;
50
51
  };
@@ -52,13 +53,13 @@ var Chunk = function(file, mongoObject, writeConcern) {
52
53
  /**
53
54
  * Writes a data to this object and advance the read/write head.
54
55
  *
55
- * @param data {string} the data to write
56
+ * @param data {string} the data to write
56
57
  * @param callback {function(*, GridStore)} This will be called after executing
57
58
  * this method. The first parameter will contain null and the second one
58
59
  * will contain a reference to this object.
59
60
  */
60
61
  Chunk.prototype.write = function(data, callback) {
61
- this.data.write(data, this.internalPosition);
62
+ this.data.write(data, this.internalPosition, data.length, 'binary');
62
63
  this.internalPosition = this.data.length();
63
64
  if(callback != null) return callback(null, this);
64
65
  return this;
@@ -150,39 +151,35 @@ Chunk.prototype.save = function(options, callback) {
150
151
  if(err) return callback(err);
151
152
 
152
153
  // Merge the options
153
- var writeOptions = {};
154
+ var writeOptions = { upsert: true };
154
155
  for(var name in options) writeOptions[name] = options[name];
155
- for(var name in self.writeConcern) writeOptions[name] = self.writeConcern[name];
156
-
157
- // collection.remove({'_id':self.objectId}, self.writeConcern, function(err, result) {
158
- collection.remove({'_id':self.objectId}, writeOptions, function(err, result) {
159
- if(err) return callback(err);
160
-
161
- if(self.data.length() > 0) {
162
- self.buildMongoObject(function(mongoObject) {
163
- var options = {forceServerObjectId:true};
164
- for(var name in self.writeConcern) {
165
- options[name] = self.writeConcern[name];
166
- }
167
-
168
- collection.insert(mongoObject, writeOptions, function(err, collection) {
169
- callback(err, self);
170
- });
156
+ for(var name in self.writeConcern) writeOptions[name] = self.writeConcern[name];
157
+
158
+ if(self.data.length() > 0) {
159
+ self.buildMongoObject(function(mongoObject) {
160
+ var options = {forceServerObjectId:true};
161
+ for(var name in self.writeConcern) {
162
+ options[name] = self.writeConcern[name];
163
+ }
164
+
165
+ collection.replaceOne({'_id':self.objectId}, mongoObject, writeOptions, function(err, collection) {
166
+ callback(err, self);
171
167
  });
172
- } else {
173
- callback(null, self);
174
- }
175
- });
168
+ });
169
+ } else {
170
+ callback(null, self);
171
+ }
172
+ // });
176
173
  });
177
174
  };
178
175
 
179
176
  /**
180
177
  * Creates a mongoDB object representation of this chunk.
181
178
  *
182
- * @param callback {function(Object)} This will be called after executing this
179
+ * @param callback {function(Object)} This will be called after executing this
183
180
  * method. The object will be passed to the first parameter and will have
184
181
  * the structure:
185
- *
182
+ *
186
183
  * <pre><code>
187
184
  * {
188
185
  * '_id' : , // {number} id for this chunk
@@ -233,4 +230,4 @@ Object.defineProperty(Chunk.prototype, "position", { enumerable: true
233
230
  */
234
231
  Chunk.DEFAULT_CHUNK_SIZE = 1024 * 255;
235
232
 
236
- module.exports = Chunk;
233
+ module.exports = Chunk;