Skip to content
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

feat(NODE-4522)!: remove callback support #3499

Merged
merged 37 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
17e87cf
test(NODE-4919): import mongodb-legacy in tests
nbbeeken Jan 4, 2023
82ac2b9
move test file, update coverage
nbbeeken Jan 19, 2023
4ac5a2f
test(NODE-4919): import mongodb-legacy in tests
nbbeeken Jan 4, 2023
d71a302
feat: remove callbacks from admin.ts
nbbeeken Dec 20, 2022
b1d5971
feat: remove callbacks from bulk/common.ts
nbbeeken Dec 20, 2022
af01cc7
feat: remove callbacks from change_stream.ts
nbbeeken Dec 20, 2022
28d2093
feat: remove callbacks from collection.ts
nbbeeken Dec 20, 2022
16ee978
feat: remove callbacks from cursors
nbbeeken Dec 20, 2022
5623462
feat: remove callbacks from db.ts
nbbeeken Dec 20, 2022
53ad68e
feat: remove callbacks from mongo_client.ts
nbbeeken Dec 20, 2022
51b0649
feat: remove callbacks from sessions.ts
nbbeeken Dec 20, 2022
bfaf3c9
feat: remove callbacks from gridfs
nbbeeken Dec 20, 2022
217101d
async keyword withTransaction and agg.explain
nbbeeken Jan 19, 2023
ffcd2d8
fle: bump to promise first fle commit
nbbeeken Jan 20, 2023
5f43565
fix: withSession
nbbeeken Jan 20, 2023
c3f2769
rm test file
nbbeeken Jan 20, 2023
4d67771
fix: lint
nbbeeken Jan 20, 2023
7a015e5
fix and skip tests
nbbeeken Jan 20, 2023
84f4f9a
jira ticket
nbbeeken Jan 20, 2023
7c06196
fix: await things
nbbeeken Jan 20, 2023
c1d5738
flip messages to check
nbbeeken Jan 20, 2023
266ec54
use fle alpha
nbbeeken Jan 20, 2023
2a1ee77
round one: fight
nbbeeken Jan 20, 2023
c12c401
comments
nbbeeken Jan 21, 2023
fb12143
consistent default arguments
nbbeeken Jan 21, 2023
e0b9538
fix tests, migration
nbbeeken Jan 21, 2023
43a0dbb
strangely close returns undefined
nbbeeken Jan 21, 2023
1ee4f9a
fix test
nbbeeken Jan 21, 2023
66a8942
Merge branch 'main' into NODE-4522-rm-callbacks
nbbeeken Jan 21, 2023
a11d175
argument defaulting fix
nbbeeken Jan 21, 2023
cad2804
fixup test
nbbeeken Jan 21, 2023
5b7dc71
fix async function strangeness
nbbeeken Jan 22, 2023
b489aca
handle close error
nbbeeken Jan 23, 2023
c0b36a9
migration suggestions
nbbeeken Jan 23, 2023
b91886c
rm todos
nbbeeken Jan 23, 2023
b0fda7d
Merge branch 'main' into NODE-4522-rm-callbacks
nbbeeken Jan 23, 2023
5c54370
Merge branch 'main' into NODE-4522-rm-callbacks
nbbeeken Jan 23, 2023
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
6 changes: 3 additions & 3 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,7 @@ tasks:
- func: bootstrap kms servers
- func: run custom csfle tests
vars:
CSFLE_GIT_REF: ff9e095eaf72f9e442761f69080dae159a395d94
CSFLE_GIT_REF: 3b3d0ebd2b180f4cb63adf937ecd985fce7e217b
- name: run-custom-csfle-tests-5.0-master
tags:
- run-custom-dependency-tests
Expand Down Expand Up @@ -2162,7 +2162,7 @@ tasks:
- func: bootstrap kms servers
- func: run custom csfle tests
vars:
CSFLE_GIT_REF: ff9e095eaf72f9e442761f69080dae159a395d94
CSFLE_GIT_REF: 3b3d0ebd2b180f4cb63adf937ecd985fce7e217b
- name: run-custom-csfle-tests-rapid-master
tags:
- run-custom-dependency-tests
Expand Down Expand Up @@ -2192,7 +2192,7 @@ tasks:
- func: bootstrap kms servers
- func: run custom csfle tests
vars:
CSFLE_GIT_REF: ff9e095eaf72f9e442761f69080dae159a395d94
CSFLE_GIT_REF: 3b3d0ebd2b180f4cb63adf937ecd985fce7e217b
- name: run-custom-csfle-tests-latest-master
tags:
- run-custom-dependency-tests
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ BUILD_VARIANTS.push({
const oneOffFuncAsTasks = []

for (const version of ['5.0', 'rapid', 'latest']) {
for (const ref of ['ff9e095eaf72f9e442761f69080dae159a395d94', 'master']) {
for (const ref of ['3b3d0ebd2b180f4cb63adf937ecd985fce7e217b', 'master']) {
oneOffFuncAsTasks.push({
name: `run-custom-csfle-tests-${version}-${ref === 'master' ? ref : 'pinned-commit'}`,
tags: ['run-custom-dependency-tests'],
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ else
source "$DRIVERS_TOOLS"/.evergreen/csfle/set-temp-creds.sh
fi

npm install mongodb-client-encryption@">=2.3.0"
npm install mongodb-client-encryption@">=2.4.0-alpha.0"
npm install @mongodb-js/zstd
npm install snappy

Expand Down
49 changes: 48 additions & 1 deletion etc/notes/CHANGES_5.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,56 @@ The following is a detailed collection of the changes in the major v5 release of

## Changes
dariakp marked this conversation as resolved.
Show resolved Hide resolved

### Callback support migrated to `mongodb-legacy`
nbbeeken marked this conversation as resolved.
Show resolved Hide resolved

If you are a callback user and you are not ready to use promises support for your workflow has **not** been removed.
nbbeeken marked this conversation as resolved.
Show resolved Hide resolved
We have migrated it to a new package:

- [`mongodb-legacy` Github](https://github.com/mongodb-js/nodejs-mongodb-legacy#readme)
- [`mongodb-legacy` npm](https://www.npmjs.com/package/mongodb-legacy)

The package wraps all of the driver's asynchronous operations and provides the _optional_ callback support. All the wrapped APIs offer an optional callback argument or a Promise return value so projects with mixed usage will continue to work.
nbbeeken marked this conversation as resolved.
Show resolved Hide resolved

#### Example usage of equivalent callback and promise usage

After installing the package and modifying imports the following example demonstrates equivalent usages of either `async`/`await` syntax, `.then`/`.catch` chaining, or callbacks:

```ts
// Just add '-legacy' to my mongodb import
import { MongoClient } from 'mongodb-legacy';
const client = new MongoClient();
const db = client.db();
const collection = db.collection('pets');

// Legacy projects may have intermixed API usage:
app.get('/endpoint_async_await', async (req, res) => {
try {
const result = await collection.findOne({})
res.end(JSON.stringify(result));
} catch (error) {
res.errorHandling(error)
}
});

app.get('/endpoint_promises', (req, res) => {
collection
.findOne({})
.then(result => res.end(JSON.stringify(result)))
.catch(error => res.errorHandling(error));
});

app.get('/endpoint_callbacks', (req, res) => {
collection.findOne({}, (error, result) => {
if (error) return res.errorHandling(error);
res.end(JSON.stringify(result));
});
});
```


### Dot Notation Typescript Support Removed By Default

**NOTE** This is a **Typescript compile-time only** change. Dot notation in filters sent to MongoDB will still work the same.
**NOTE:** This is a **Typescript compile-time only** change. Dot notation in filters sent to MongoDB will still work the same.

Version 4.3.0 introduced Typescript support for dot notation in filter predicates. For example:

Expand Down
Loading