All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
- Custom fetch: For
db()andcollection(), there is now a chainablefetch()method, which returns a new DB or collection with itsfetchimplementation changed. This allows you to implement your own custom logic for retries, without the addition of pRetry
- Removed pRetry dependency in favor of users overriding via their own fetch function
- Updated minimum node version to
>=18.0.0 - Package is now ESM-only. One major reason for this change is that TypeScript now understands ESM importing naturally, making it easy to use this package in TypeScript projects without any additional configuration. If you are using CommonJS, you will need to use a bundler such as Webpack or Rollup to use this package, or import the library dynamically using
await import("mongo-data-api"). The following snippet will provide support for importing your module safely in CommonJS.
let mongoDataApiClient: MongoClient | undefined;
const createMongoClient = async () => {
if (mongoDataApiClient) return mongoDataApiClient;
const { MongoClient } = await import("mongo-data-api");
mongoDataApiClient = new MongoClient(/*options*/);
return mongoDataApiClient;
};- Smart retries via
p-retryfor hard failures such asECONNRESETandECONNREFUSED
- Return type on
insertOneis now of typeObjectIdinstead ofstring
undefinedvalues in top level fields (sort, projection, etc) cause400from mongo #1
0.2.1 - 2023-05-02
- Updated typescript documentation for
fetch?
0.2.0 - 2023-05-02
fetch is now a standard fetch function, and no longer an object requiring Request, Response, and Headers
When providing a custom fetch() function, it's no longer required to also pass the other elements such as Request, Response and Headers. This increases the number of libraries you can use with fetch.
// OLD
const c = new MongoClient({
endpoint: BASE_URL,
dataSource: "test-datasource",
auth: { apiKey: "validApiKey" },
fetch: {
// fetch interface
},
});
// NEW
const c = new MongoClient({
endpoint: BASE_URL,
dataSource: "test-datasource",
auth: { apiKey: "validApiKey" },
fetch: ponyfillFetch, // "as typeof fetch" may be required for some fetch libraries
});- Created a
CHANGELOG.mdfor changelog tracking - Enabled support for plain JS objects in
headers
- Removed requirement for
RequestandResponsein the custom fetch interface
- Dropped
node-fetchforcross-fetchin tests to minimze type assertions
0.1.2 - 2023-05-01
- Mongo Data API (all methods)
- Mongo Data API Auth
- Documentation
- Tests
- Standardized Release Process
Older releases are available via github releases: https://github.com/taskless/mongo-data-api/releases