Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,11 @@ var collectionOperationsMap = {
var err = ShareDbMongo.malformedQueryOperatorError('$mapReduce');
return cb(err);
}
// This function was removed in mongodb5:
// https://github.com/mongodb/node-mongodb-native/pull/3511
if (typeof collection.mapReduce !== 'function') {
var err = ShareDbMongo.$mapReduceDisabledError();
}
var mapReduceOptions = {
query: query,
out: {inline: 1},
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "MongoDB database adapter for ShareDB",
"main": "index.js",
"dependencies": {
"mongodb": "^2.1.2 || ^3.1.13 || ^4.0.0",
"mongodb": "^2.1.2 || ^3.1.13 || ^4.0.0 || ^5.0.0",
"sharedb": "^1.9.1 || ^2.0.0 || ^3.0.0"
},
"devDependencies": {
Expand All @@ -16,6 +16,7 @@
"mongodb2": "npm:mongodb@^2.1.2",
"mongodb3": "npm:mongodb@^3.0.0",
"mongodb4": "npm:mongodb@^4.0.0",
"mongodb5": "npm:mongodb@^5.0.0",
"nyc": "^14.1.1",
"ot-json1": "^1.0.1",
"sharedb-mingo-memory": "^1.1.1",
Expand All @@ -29,7 +30,8 @@
"test:mongodb2": "_SHAREDB_MONGODB_DRIVER=mongodb2 npm test",
"test:mongodb3": "_SHAREDB_MONGODB_DRIVER=mongodb3 npm test",
"test:mongodb4": "_SHAREDB_MONGODB_DRIVER=mongodb4 npm test",
"test:all": "npm run test:mongodb2 && npm run test:mongodb3 && npm run test:mongodb4",
"test:mongodb5": "_SHAREDB_MONGODB_DRIVER=mongodb5 npm test",
"test:all": "npm run test:mongodb2 && npm run test:mongodb3 && npm run test:mongodb4 && npm run test:mongodb5",
"test-cover": "nyc --temp-dir=coverage -r text -r lcov npm run test:all"
},
"repository": "git://github.com/share/sharedb-mongo.git",
Expand Down
5 changes: 5 additions & 0 deletions test/test_mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ describe('mongo db', function() {
});

it('$mapReduce queries should work when allowJavaScriptQuery == true', function(done) {
if (process.env._SHAREDB_MONGODB_DRIVER === 'mongodb5') {
// This function was removed in mongodb5:
// https://github.com/mongodb/node-mongodb-native/pull/3511
return done();
}
var snapshots = [
{type: 'json0', v: 1, data: {player: 'a', round: 1, score: 5}},
{type: 'json0', v: 1, data: {player: 'a', round: 2, score: 7}},
Expand Down