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.
- package/HISTORY.md +574 -429
- package/Makefile +2 -5
- package/README.md +108 -15
- package/conf.json +17 -13
- package/index.js +13 -2
- package/lib/admin.js +113 -47
- package/lib/aggregation_cursor.js +56 -28
- package/lib/apm.js +608 -0
- package/lib/bulk/common.js +7 -7
- package/lib/bulk/ordered.js +56 -17
- package/lib/bulk/unordered.js +52 -14
- package/lib/collection.js +671 -212
- package/lib/command_cursor.js +60 -32
- package/lib/cursor.js +313 -115
- package/lib/db.js +264 -105
- package/lib/gridfs/chunk.js +26 -29
- package/lib/gridfs/grid_store.js +150 -64
- package/lib/gridfs-stream/download.js +310 -0
- package/lib/gridfs-stream/index.js +335 -0
- package/lib/gridfs-stream/upload.js +450 -0
- package/lib/metadata.js +64 -0
- package/lib/mongo_client.js +69 -39
- package/lib/mongos.js +65 -20
- package/lib/replset.js +69 -34
- package/lib/server.js +35 -1
- package/lib/topology_base.js +22 -10
- package/lib/url_parser.js +111 -13
- package/lib/utils.js +9 -8
- package/mongolabs.js +427 -0
- package/package.json +8 -6
- package/t.js +68 -51
- package/test.js +12 -0
- package/test_boot/boot.sh +3 -0
- package/test_boot/ca.pem +49 -0
- package/test_boot/client.pem +48 -0
- package/test_boot/client_password.pem +51 -0
- package/test_boot/connect.js +29 -0
- package/test_boot/data/WiredTiger +2 -0
- package/test_boot/data/WiredTiger.lock +1 -0
- package/test_boot/data/WiredTiger.turtle +6 -0
- package/test_boot/data/WiredTiger.wt +0 -0
- package/test_boot/data/WiredTigerLAS.wt +0 -0
- package/test_boot/data/_mdb_catalog.wt +0 -0
- package/test_boot/data/collection-0-757073248613337118.wt +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-44-37Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-45-15Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-46-31Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-47-25Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-49-07Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-50-41Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-50-53Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-52-31Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-54-53Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-55-09Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-55-38Z-00000 +0 -0
- package/test_boot/data/index-1-757073248613337118.wt +0 -0
- package/test_boot/data/mongod.lock +0 -0
- package/test_boot/data/sizeStorer.wt +0 -0
- package/test_boot/data/storage.bson +0 -0
- package/test_boot/server_password.pem +51 -0
- package/.travis.yml +0 -10
- package/t1.js +0 -59
- package/wercker.yml +0 -19
package/lib/gridfs/chunk.js
CHANGED
|
@@ -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'
|
|
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
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
}
|
|
173
|
-
|
|
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;
|