Skip to content
Merged

v6 #141

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
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ permissions:
jobs:
test:
# os is not in the matrix, because otherwise there would be way too many testing instances
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
node: [14, 16, 18]
mongo: [4.2, 5.0]
node: ['20', '22', '24']
mongo: [7.0, 8.0]
services:
mongodb:
image: mongo:${{ matrix.mongo }}
Expand Down
4 changes: 3 additions & 1 deletion lib/collection/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ const methods = [
'updateMany',
'updateOne',
'replaceOne',
'count',
'countDocuments',
'estimatedDocumentCount',
'distinct',
'findOneAndDelete',
'findOneAndReplace',
'findOneAndUpdate',
'aggregate',
'findCursor',
Expand Down
20 changes: 17 additions & 3 deletions lib/collection/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ class NodeCollection extends Collection {
}

/**
* count(match, options)
* countDocuments(match, options)
*/
async count(match, options) {
return this.collection.count(match, options);
async countDocuments(match, options) {
return this.collection.countDocuments(match, options);
}

/**
* estimatedDocumentCount(match, options)
*/
async estimatedDocumentCount(match, options) {
return this.collection.estimatedDocumentCount(match, options);
Comment on lines +41 to +44
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

The estimatedDocumentCount method is passing match parameter to MongoDB's estimatedDocumentCount(), but this method doesn't accept a filter/match parameter - it only accepts options. According to MongoDB documentation, estimatedDocumentCount() estimates the count of all documents in the collection based on collection metadata, and cannot filter by conditions.

The signature should be:

async estimatedDocumentCount(options) {
  return this.collection.estimatedDocumentCount(options);
}

And the comment should be updated to:

/**
 * estimatedDocumentCount(options)
 */
Suggested change
* estimatedDocumentCount(match, options)
*/
async estimatedDocumentCount(match, options) {
return this.collection.estimatedDocumentCount(match, options);
* estimatedDocumentCount(options)
*/
async estimatedDocumentCount(options) {
return this.collection.estimatedDocumentCount(options);

Copilot uses AI. Check for mistakes.
}

/**
Expand Down Expand Up @@ -93,6 +100,13 @@ class NodeCollection extends Collection {
return this.collection.findOneAndUpdate(match, update, options);
}

/**
* findOneAndReplace(match, update, options)
*/
async findOneAndReplace(match, update, options) {
return this.collection.findOneAndReplace(match, update, options);
}

/**
* var cursor = findCursor(match, options)
*/
Expand Down
Loading
Loading