-
Notifications
You must be signed in to change notification settings - Fork 4
Upgrade to MongoDB Driver v6 #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
901adb4
Use `[email protected]`.
mattcollier a5b9b23
Remove unsupported client options.
mattcollier be62faf
Add config and test for promoteBuffers.
mattcollier 1079b8c
Add assertion for `insertOne` response.
mattcollier 2976868
Change user to username.
mattcollier 581d742
Remove `writeConcern` options.
mattcollier 331795a
Set min server version to 5.
mattcollier 2b5ec4f
Update copyright notices.
mattcollier ab631aa
Remove use of `_usesRoles` helper.
mattcollier 9fe556d
Limit ops to url only.
mattcollier 506c7f7
Disable connectOptions.
mattcollier fe503b1
Modify conditional around `_addAuthOptions`.
mattcollier 9a1e8f2
Refactor `openDatabase`.
mattcollier 7afbbff
Code clean-up.
mattcollier e93054d
Refactor code in test.
mattcollier 84513f4
Update readme.
mattcollier f2bbdff
Add `MongoServerError` to the exceptions list.
mattcollier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,12 +58,10 @@ bedrock.start(); | |
| For documentation on database configuration, see [config.js](./lib/config.js). | ||
|
|
||
| ### Connecting and Authenticating | ||
| MongoDB's documentation offers tons of great examples on how to authenticate | ||
| using a myriad number of connection strings. | ||
| MongoDB's documentation provides examples on how to authenticate using a myriad | ||
| number of connection strings. | ||
|
|
||
| [Mongo Node 3.5 Driver connect docs](http://mongodb.github.io/node-mongodb-native/3.5/tutorials/connect/) | ||
|
|
||
| [Mongo Node 3.5 Driver atlas docs](https://docs.mongodb.com/drivers/node#connect-to-mongodb-atlas) | ||
| [Mongo Node Driver connect docs](https://www.mongodb.com/docs/drivers/node/current/fundamentals/connection/connect/) | ||
|
|
||
| You can also connect to access-enabled mongo servers using some small changes to the | ||
| `config.mongodb.connectOptions`: | ||
|
|
@@ -94,9 +92,9 @@ config.mongodb.url = 'mongodb://myDBReader:D1fficultP%[email protected]. | |
| ## Requirements | ||
|
|
||
| * Linux or Mac OS X (also works on Windows with some coaxing) | ||
| * node.js >= 14.x | ||
| * npm >= 6.x | ||
| * mongodb ~= 4.x | ||
| * node.js >= 18.x | ||
| * npm >= 9.x | ||
| * mongodb >= 5.x | ||
| * libkrb5-dev >= 1.x.x | ||
|
|
||
| ## Setup | ||
|
|
@@ -105,7 +103,7 @@ config.mongodb.url = 'mongodb://myDBReader:D1fficultP%[email protected]. | |
| at [mongodb.org](http://docs.mongodb.org/manual/tutorial/add-user-administrator/) | ||
| for your version of MongoDB. Version 4.2.x is currently supported. | ||
| 2. [optional] Tweak your project's configuration settings; see | ||
| [Configuration](#configuration) or [Quick Examples](#quickexamples). | ||
| [Configuration](#configuration) or [Quick Examples](#quick-examples). | ||
|
|
||
| ## API | ||
|
|
||
|
|
@@ -122,13 +120,12 @@ an error occurs, the returned promise rejects. If no error occurs, then once | |
| the promise resolves, the `collections` object will have keys that match the | ||
| collection names and values that are instances of | ||
| [mongodb-native][] | ||
| [Collection](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html). | ||
| [Collection](https://mongodb.github.io/node-mongodb-native/6.3/classes/Collection.html). | ||
|
|
||
| ### createGridFSBucket(options) | ||
|
|
||
| Creates and returns a new `GridFSBucket` from the native driver. Options are | ||
| the same as for `GridFSBucket`. The current client is used and the | ||
| `writeConcern` option defaults to the `writeOptions` config value. | ||
| the same as for `GridFSBucket`. The current client is used. | ||
|
|
||
| ## Test Mode | ||
| ### Drop Collections on Initialization | ||
|
|
@@ -152,4 +149,4 @@ bedrock.config.mongodb.dropCollections.collections = []; | |
| ``` | ||
|
|
||
| [bedrock]: https://github.com/digitalbazaar/bedrock | ||
| [mongodb-native]: http://mongodb.github.io/node-mongodb-native/3.5/ | ||
| [mongodb-native]: https://www.mongodb.com/docs/drivers/node/current/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /*! | ||
| * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved. | ||
| * Copyright (c) 2012-2024 Digital Bazaar, Inc. All rights reserved. | ||
| */ | ||
| import * as bedrock from '@bedrock/core'; | ||
| import * as urls from './urls.js'; | ||
|
|
@@ -81,12 +81,8 @@ export async function openCollections(names) { | |
| // open the collections | ||
| logger.debug('opening collections', {collections: unopened}); | ||
| const collections = {}; | ||
| const {writeConcern} = _db.options; | ||
| await Promise.all(unopened.map(async name => { | ||
| // Note: We only pass `{writeConcern}` here to get around a bug in mongodb | ||
| // node driver 3.6.4 where `writeConcern` from `db` is not passed to | ||
| // collection | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably this bug has been fixed now. |
||
| collections[name] = await _db.collection(name, {writeConcern}); | ||
| collections[name] = await _db.collection(name); | ||
| })); | ||
|
|
||
| // merge results into collection cache | ||
|
|
@@ -115,9 +111,6 @@ export async function createIndexes(options) { | |
| /** | ||
| * Creates a streaming GridFS bucket instance. | ||
| * | ||
| * By default the writeOptions config value is used for the GridFSBucket | ||
| * writeConcern option. | ||
| * | ||
| * @param {object} options - See GridFSBucket documentation. | ||
| * | ||
| * @returns {object} The new GridFSBucket instance. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /*! | ||
| * Copyright (c) 2017-2022 Digital Bazaar, Inc. All rights reserved. | ||
| * Copyright (c) 2017-2024 Digital Bazaar, Inc. All rights reserved. | ||
| */ | ||
| import {loggers} from '@bedrock/core'; | ||
| export const logger = loggers.get('app').child('bedrock-mongodb'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we mean to get rid of this comment? It's useful, IMO.