Skip to content

feat: update deps and support mongo v7 #369

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

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
840 changes: 388 additions & 452 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"semantic-release": "SEMANTIC_COMMITLINT_SKIP=f4543f643bac890c627d538e6200c5f5a1d45ebc semantic-release",
"test": "npm run test:mongoist && npm run test:native",
"test:mongoist": "DRIVER=mongoist jest --forceExit",
"test:native": "DRIVER=native jest && DRIVER=native DRIVER_VERSION=v3 jest",
Copy link
Contributor Author

@adborroto adborroto Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the support for v3, is just too old

image

"test:native": "DRIVER=native jest",
"build": "rm -rf dist/ && tsc"
},
"repository": {
Expand All @@ -40,7 +40,7 @@
"homepage": "https://github.com/mixmaxhq/mongo-cursor-pagination#readme",
"dependencies": {
"base64-url": "^2.2.0",
"bson": "^4.7.2",
"bson": "^6.10.3",
"object-path": "^0.11.8",
"projection-utils": "^1.1.0",
"semver": "^5.4.1",
Expand All @@ -52,21 +52,20 @@
"@mixmaxhq/prettier-config": "^1.0.0",
"@mixmaxhq/semantic-release-config": "^2.0.0",
"@mixmaxhq/ts-config": "^1.2.1",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.12",
"@types/node": "^18.19.70",
"@types/express": "^4.17.21",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"cz-conventional-changelog": "^3.2.0",
"eslint": "^7.32.0",
"eslint-config-mixmax": "^4.11.2",
"jest": "^29.6.2",
"mockgoose": "^8.0.4",
"mongodb": "^4.8.0",
"mongodb-memory-server": "6.9.6",
"mongodbv3": "npm:mongodb@^3.7.4",
"mongoist": "^3.0.0",
"mongoose": "^5.13.20",
"mongodb": "^6.15.0",
"mongodb-memory-server": "^10.1.4",
"mongoist": "^4.0.1",
"mongoose": "^8.12.2",
"prettier": "^1.19.1",
"semantic-release": "^17.4.7",
"ts-jest": "^29.0.5",
Expand Down
2 changes: 1 addition & 1 deletion test/aggregate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('aggregate', () => {
db: null,
};
beforeAll(async () => {
mongod = dbUtils.start();
mongod = await dbUtils.start();
({ db: t.db, client } = await dbUtils.db(mongod, driver));

// Set up collections once for testing later.
Expand Down
4 changes: 2 additions & 2 deletions test/find.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('find', () => {
db: null,
};
beforeAll(async () => {
mongod = dbUtils.start();
mongod = await dbUtils.start();
({ db: t.db, client } = await dbUtils.db(mongod, driver));

// Set up collections once for testing later.
Expand Down Expand Up @@ -757,7 +757,7 @@ describe('find', () => {
});

afterEach(async () => {
await t.db.collection('test_paging_string_ids').remove({});
await t.db.collection('test_paging_string_ids').deleteMany({});
});

it('queries first few pages with next/previous', async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/findWithReq.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('findWithReq', () => {
db: null,
};
beforeAll(async () => {
mongod = dbUtils.start();
mongod = await dbUtils.start();
({ db: t.db, client } = await dbUtils.db(mongod, driver));

await Promise.all([
Expand Down
2 changes: 1 addition & 1 deletion test/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('search', () => {
db: null,
};
beforeAll(async () => {
mongod = dbUtils.start();
mongod = await dbUtils.start();
({ db: t.db, client } = await dbUtils.db(mongod, driver));

await Promise.all([
Expand Down
19 changes: 8 additions & 11 deletions test/support/db.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { MongoMemoryServer } from 'mongodb-memory-server';
import { Db, MongoClient } from 'mongodb';
import mongoist from 'mongoist';
import { MongoClient as MongoClientV3 } from 'mongodbv3';
function start(): MongoMemoryServer {
return new MongoMemoryServer({
binary: { version: '6.0.8' },
});
}

const driver_version = process.env.DRIVER_VERSION;

async function start(): Promise<MongoMemoryServer> {
return await MongoMemoryServer.create();
}
interface DbResponse {
db: Db;
client?: MongoClient | MongoClientV3;
client?: MongoClient;
}

async function db(mongod: MongoMemoryServer, driver: string | null = null): Promise<DbResponse> {
Expand All @@ -22,8 +17,10 @@ async function db(mongod: MongoMemoryServer, driver: string | null = null): Prom
db: await mongoist(uri),
};
}
const clientToConnect = driver_version === 'v3' ? MongoClientV3 : MongoClient;
const [client, dbName] = await Promise.all([clientToConnect.connect(uri), mongod.getDbName()]);
const [client, dbName] = await Promise.all([
MongoClient.connect(uri),
mongod.instanceInfo?.dbName,
]);
return {
db: client.db(dbName),
client,
Expand Down
7 changes: 3 additions & 4 deletions test/utils/bsonUrlEncoding.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as mongo from 'mongoist';

import { ObjectId } from 'bson';
import bsonUrlEncoding from '../../src/utils/bsonUrlEncoding';
import * as dbUtils from '../support/db';

Expand All @@ -12,7 +11,7 @@ describe('bson url encoding', () => {
db: null,
};
beforeAll(async () => {
mongod = dbUtils.start();
mongod = await dbUtils.start();
({ db: t.db, client } = await dbUtils.db(mongod, driver));
});

Expand All @@ -23,7 +22,7 @@ describe('bson url encoding', () => {

it('encodes and decodes complex objects', async () => {
const obj = {
_id: mongo.ObjectID('58164d86f69ab45942c6ff38'),
_id: new ObjectId('58164d86f69ab45942c6ff38'),
date: new Date('Sun Oct 30 2016 12:32:35 GMT-0700 (PDT)'),
number: 1,
string: 'complex String &$##$-/?',
Expand Down