Skip to content

Commit 5d182b3

Browse files
committed
⬆️ Add support for mongodb5
This change adds support for [`mongodb` v5][1]. The headline breaking change here is dropping support for callbacks (and forcing consumers to use promises instead). This library already internally uses promises, so we just need to tweak a couple of tests that were using callbacks. [1]: https://github.com/mongodb/node-mongodb-native/releases/tag/v5.0.0
1 parent d59f50d commit 5d182b3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "MongoDB milestone snapshot database adapter for ShareDB",
55
"main": "lib/index.js",
66
"dependencies": {
7-
"mongodb": "^2.2.36 || ^3.0.0 || ^4.0.0",
7+
"mongodb": "^2.2.36 || ^3.0.0 || ^4.0.0 || ^5.0.0",
88
"sharedb": "^1.0.0 || ^2.0.0 || ^3.0.0"
99
},
1010
"devDependencies": {
@@ -15,6 +15,7 @@
1515
"mongodb2": "npm:mongodb@^2.2.36",
1616
"mongodb3": "npm:mongodb@^3.0.0",
1717
"mongodb4": "npm:mongodb@^4.0.0",
18+
"mongodb5": "npm:mongodb@^5.0.0",
1819
"nyc": "^15.1.0"
1920
},
2021
"scripts": {

test/mongo-milestone-db.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ const mongodbRequire = require('../lib/mongodb');
66

77
const MONGO_URL = process.env.TEST_MONGO_URL || 'mongodb://localhost:27017/test';
88

9-
['mongodb2', 'mongodb3', 'mongodb4'].forEach((driver) => {
9+
[
10+
'mongodb2',
11+
'mongodb3',
12+
'mongodb4',
13+
'mongodb5',
14+
].forEach((driver) => {
1015
const mongodb = require(driver);
1116

1217
function create(options, callback) {
@@ -111,8 +116,7 @@ const MONGO_URL = process.env.TEST_MONGO_URL || 'mongodb://localhost:27017/test'
111116

112117
db.saveMilestoneSnapshot('testcollection', snapshot, (saveError) => {
113118
if (saveError) return done(saveError);
114-
mongo.collection('m_testcollection').indexInformation((indexError, indexes) => {
115-
if (indexError) return done(indexError);
119+
mongo.collection('m_testcollection').indexInformation().then((indexes) => {
116120
expect(indexes.d_1_v_1).to.be.ok;
117121
expect(indexes['m.mtime_1']).to.be.ok;
118122
done();
@@ -163,8 +167,7 @@ const MONGO_URL = process.env.TEST_MONGO_URL || 'mongodb://localhost:27017/test'
163167

164168
db.saveMilestoneSnapshot('testcollection', snapshot, (saveError) => {
165169
if (saveError) return done(saveError);
166-
mongo.collection('m_testcollection').indexInformation((indexError, indexes) => {
167-
if (indexError) return done(indexError);
170+
mongo.collection('m_testcollection').indexInformation().then((indexes) => {
168171
expect(indexes.id_1_v_1).not.to.be.ok;
169172
done();
170173
});

0 commit comments

Comments
 (0)