Skip to content

v5.0.0

Compare
Choose a tag to compare
@nbbeeken nbbeeken released this 31 Jan 19:26
· 138 commits to main since this release
ddb7ec8

The MongoDB Node.js team is pleased to announce version 5.0.0 of the bson package!

Release Highlights

BSON v5 is out and ready to rumble!

The focus of this release was to modernize our library's approach to delivering a unified cross-platform JavaScript experience.
We no longer support EOL Node.js versions, so the new minimum requirement for the library is v14.20.1 or later.
With ES modules no longer experimental and top-level await available, BSON now offers a native ESM bundle that works in Node.js and the browser in addition to the existing CommonJS format.

Remove reliance on Node.js Buffer

Our main improvement centers around the code's use of Uint8Array on the web and Buffer in Node.js.
By pulling out all the byte-by-byte helpers needed to parse and create BSON documents we were able to accomplish the original vision of the Node.js project: true isomorphism (almost!). Our ES module build of the library is runnable in Node.js and the browser, without shims or polyfills. We are so excited for this "write once, run everywhere" future!

The Remove reliance on Node.js Buffer section in the migration guide provides more detail.

Use BigInt with BSON and EJSON

Speaking of modernization, we are delighted to announce support for BigInt as a native way to represent and interact with BSON int64s!

JavaScript introduced an infinite precision integer type called BigInt in 2018. BSON 5.0 supports Nodejs 14+, which enables us to use it as an alternate numeric representation for BSON Longs. You can start sending BigInts down into BSON right away: BSON.serialize and EJSON.stringify understand how to convert them into BSON Long and EJSON's $numberLong format.

Returning BigInts is not enabled by default, however this can be accomplished by adding the useBigInt64: true flag in BSON.deserialize or EJSON.parse. For more information on how we transform BigInt’s to 64-bit Integers see the abstract ToBigInt64 operation.

Note: Full support for this feature is not going to be available in the driver v5.0.0 release, we are intending to make it available in the first feature release after 5.0.0

Upgrade today!

We have a detailed migration guide that provides more context on the changes listed below.

We hope you love BSON as much as we do. 💚 🧑‍💻

⚠ BREAKING CHANGES

Features

Use BigInt with BSON and EJSON

Other Features

Removals and Breaking Fixes

Bug Fixes

Documentation

We invite you to try the bson library and report any issues to the NODE project.