Skip to content

Commit

Permalink
upgrade mongodb driver to ~6
Browse files Browse the repository at this point in the history
  • Loading branch information
pirxpilot committed Dec 24, 2023
1 parent 1533197 commit a142f1f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,17 @@ function collection({ db, name, indexes = [] }) {
async function findOneAndDelete(query, options = {}) {
debug('findOneAndDelete %j', query);
const collection = await open();
const { value } = await collection.findOneAndDelete(query, options);
return value;
return collection.findOneAndDelete(query, options);
}

async function findOneAndReplace(query, replacement, options = {}) {
debug('findOneAndReplace %j %j', query, replacement);
const collection = await open();
const { value } = await collection.findOneAndReplace(
return collection.findOneAndReplace(
query,
replacement,
options
);
return value;
}

async function findOneAndUpdate(query, update, options = {}) {
Expand All @@ -138,8 +136,7 @@ function collection({ db, name, indexes = [] }) {
...options
};
const collection = await open();
const result = await collection.findOneAndUpdate(query, update, options);
return result?.value;
return await collection.findOneAndUpdate(query, update, options);
}

async function findOne(query, options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"license": "MIT",
"dependencies": {
"debug": "~4",
"mongodb": "~5"
"mongodb": "~6"
},
"devDependencies": {
"@pirxpilot/jshint": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion test/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('query', async function () {
{ updateOne: { filter: { _id: 3 }, update: { $set: { name: 'c' } } } }
]);

assert.equal(results.nModified, 3);
assert.equal(results.modifiedCount, 3);

async function insert() {
const tasks = [];
Expand Down

0 comments on commit a142f1f

Please sign in to comment.