Skip to content

Commit 1f7b0ff

Browse files
committed
integrated the new bson parser and mongodb-core 2.1.0
1 parent 52f3b3c commit 1f7b0ff

File tree

5 files changed

+27
-18
lines changed

5 files changed

+27
-18
lines changed

lib/bulk/ordered.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ var common = require('./common')
1212
, Batch = common.Batch
1313
, mergeBatchResults = common.mergeBatchResults;
1414

15-
var bson = new BSON.BSONPure();
15+
var bson = new BSON([BSON.Binary, BSON.Code, BSON.DBRef, BSON.Decimal128,
16+
BSON.Double, BSON.Int32, BSON.Long, BSON.Map, BSON.MaxKey, BSON.MinKey,
17+
BSON.ObjectId, BSON.BSONRegExp, BSON.Symbol, BSON.Timestamp]);
1618

1719
/**
1820
* Create a FindOperatorsOrdered instance (INTERNAL TYPE, do not instantiate directly)
@@ -148,7 +150,9 @@ FindOperatorsOrdered.prototype.remove = FindOperatorsOrdered.prototype.delete;
148150
// Add to internal list of documents
149151
var addToOperationsList = function(_self, docType, document) {
150152
// Get the bsonSize
151-
var bsonSize = bson.calculateObjectSize(document, false);
153+
var bsonSize = bson.calculateObjectSize(document, {
154+
checkKeys: false,
155+
});
152156

153157
// Throw error if the doc is bigger than the max BSON size
154158
if(bsonSize >= _self.s.maxBatchSizeBytes) {

lib/bulk/unordered.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ var common = require('./common')
1212
, Batch = common.Batch
1313
, mergeBatchResults = common.mergeBatchResults;
1414

15-
var bson = new BSON.BSONPure();
15+
var bson = new BSON([BSON.Binary, BSON.Code, BSON.DBRef, BSON.Decimal128,
16+
BSON.Double, BSON.Int32, BSON.Long, BSON.Map, BSON.MaxKey, BSON.MinKey,
17+
BSON.ObjectId, BSON.BSONRegExp, BSON.Symbol, BSON.Timestamp]);
1618

1719
/**
1820
* Create a FindOperatorsUnordered instance (INTERNAL TYPE, do not instantiate directly)
@@ -145,7 +147,9 @@ FindOperatorsUnordered.prototype.remove = function() {
145147
//
146148
var addToOperationsList = function(_self, docType, document) {
147149
// Get the bsonSize
148-
var bsonSize = bson.calculateObjectSize(document, false);
150+
var bsonSize = bson.calculateObjectSize(document, {
151+
checkKeys: false,
152+
});
149153
// Throw error if the doc is bigger than the max BSON size
150154
if(bsonSize >= _self.s.maxBatchSizeBytes) throw toError("document is larger than the maximum size " + _self.s.maxBatchSizeBytes);
151155
// Holds the current batch

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
],
1515
"dependencies": {
1616
"es6-promise": "3.2.1",
17-
"mongodb-core": "2.0.14",
17+
"mongodb-core": "christkv/mongodb-core#1.0-bson-port",
1818
"readable-stream": "2.1.5"
1919
},
2020
"devDependencies": {
2121
"JSONStream": "^1.0.7",
2222
"betterbenchmarks": "^0.1.0",
2323
"bluebird": "3.4.6",
24-
"bson": "^0.5.1",
24+
"bson": "mongodb/js-bson#1.0-branch",
2525
"cli-table": "^0.3.1",
2626
"co": "4.6.0",
2727
"colors": "^1.1.2",

test/functional/raw_tests.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
"use strict";
22

3+
var BSON = require('mongodb-core').BSON;
4+
var bson = new BSON([BSON.Binary, BSON.Code, BSON.DBRef, BSON.Decimal128,
5+
BSON.Double, BSON.Int32, BSON.Long, BSON.Map, BSON.MaxKey, BSON.MinKey,
6+
BSON.ObjectId, BSON.BSONRegExp, BSON.Symbol, BSON.Timestamp]);
7+
38
/**
49
* @ignore
510
*/
@@ -8,9 +13,7 @@ exports.shouldCorrectlySaveDocumentsAndReturnAsRaw = {
813

914
// The actual test we wish to run
1015
test: function(configuration, test) {
11-
var Buffer = require('buffer').Buffer
12-
, BSON = require('mongodb-core').BSON.pure().BSON;
13-
// console.dir(BSON)
16+
var Buffer = require('buffer').Buffer;
1417

1518
var db = configuration.newDbInstance({w:1}, {poolSize:1});
1619
db.open(function(err, db) {
@@ -22,8 +25,8 @@ exports.shouldCorrectlySaveDocumentsAndReturnAsRaw = {
2225
var objects = [];
2326

2427
for(var i = 0; i < items.length; i++) {
25-
test.ok(Buffer.isBuffer(items[i]));
26-
objects.push(new BSON().deserialize(items[i]));
28+
test.ok(Buffer.isBuffer(items[i]));
29+
objects.push(bson.deserialize(items[i]));
2730
}
2831

2932
test.equal(1, objects[0].a);
@@ -33,7 +36,7 @@ exports.shouldCorrectlySaveDocumentsAndReturnAsRaw = {
3336
// Execute findOne
3437
collection.findOne({a:1}, {raw:true}, function(err, item) {
3538
test.ok(Buffer.isBuffer(item));
36-
var object = new BSON().deserialize(item);
39+
var object = bson.deserialize(item);
3740
test.equal(1, object.a)
3841
db.close();
3942
test.done();
@@ -53,9 +56,7 @@ exports.shouldCorrectlySaveDocumentsAndReturnAsRawWithRawSetAtCollectionLevel =
5356

5457
// The actual test we wish to run
5558
test: function(configuration, test) {
56-
var Buffer = require('buffer').Buffer
57-
, BSON = require('mongodb-core').BSON.pure().BSON;
58-
// console.dir(BSON)
59+
var Buffer = require('buffer').Buffer;
5960

6061
var db = configuration.newDbInstance({w:1}, {poolSize:1});
6162
db.open(function(err, db) {
@@ -67,7 +68,7 @@ exports.shouldCorrectlySaveDocumentsAndReturnAsRawWithRawSetAtCollectionLevel =
6768
var objects = [];
6869
for(var i = 0; i < items.length; i++) {
6970
test.ok(Buffer.isBuffer(items[i]));
70-
objects.push(new BSON().deserialize(items[i]));
71+
objects.push(bson.deserialize(items[i]));
7172
}
7273

7374
test.equal(1, objects[0].a);
@@ -77,7 +78,7 @@ exports.shouldCorrectlySaveDocumentsAndReturnAsRawWithRawSetAtCollectionLevel =
7778
// Execute findOne
7879
collection.findOne({a:1}, {raw:true}, function(err, item) {
7980
test.ok(Buffer.isBuffer(item));
80-
var object = new BSON().deserialize(item);
81+
var object = bson.deserialize(item);
8182
test.equal(1, object.a)
8283
db.close();
8384
test.done();

test/mock/lib/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var net = require('net'),
22
Long = require('bson').Long,
3-
BSON = require('bson').pure().BSON,
3+
BSON = require('bson'),
44
Request = require('./request'),
55
Query = require('./protocol').Query,
66
GetMore = require('./protocol').GetMore,

0 commit comments

Comments
 (0)