[DOCS-12966] Investigate changes in SERVER-37690: countDocuments throws an error when matching 0 document Created: 19/Aug/19  Updated: 13/Nov/23  Resolved: 04/Oct/19

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 4.3.1, 4.2.1, 4.0.13, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Jeffrey Allen
Resolution: Fixed Votes: 0
Labels: docs-onboarding-candidate
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-37690 countDocuments throws an error when m... Closed
Participants:
Days since reply: 4 years, 16 weeks, 5 days ago
Epic Link: DOCS: 4.4 Server Release Work

 Description   

Description

Downstream Change Summary

The shell's countDocuments method had thrown an uninformative error if the collection is empty or does not exist. Now it will return 0, the same as drivers do.

Description of Linked Ticket

`countDocuments` throws an error when matching 0 document.

I would have expected it to follow what `count` does, which is return 0.

With both versions `4.0.3` and `4.1.4` (haven't checked intermediary ones), the error I get from the bellow `steps to reproduce` is:

2018-10-20T16:26:44.252+0100 E QUERY [js] TypeError: res[0] is undefined :
 DBCollection.prototype.countDocuments@src/mongo/shell/collection.js:1418:5
 @(shell):1:1
 

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Githook User [ 18/Oct/19 ]

Author:

{'name': 'jeff-allen-mongo', 'username': 'jeff-allen-mongo', 'email': 'jeffrey.allen@10gen.com'}

Message: (DOCS-12966): Updating behavior for countDocuments on empty collections
Branch: master
https://github.com/mongodb/docs/commit/3986f0e01b7a6c045abb2f78c14e9c05e104d715

Comment by Githook User [ 18/Oct/19 ]

Author:

{'name': 'jeff-allen-mongo', 'username': 'jeff-allen-mongo', 'email': 'jeffrey.allen@10gen.com'}

Message: (DOCS-12966): Updating behavior for countDocuments on empty collections
Branch: v4.2.1
https://github.com/mongodb/docs/commit/bcd84cdac5affd7edcf98071da2e5f24426c3970

Comment by Githook User [ 18/Oct/19 ]

Author:

{'username': 'jeff-allen-mongo', 'email': 'jeffrey.allen@10gen.com', 'name': 'jeff-allen-mongo'}

Message: (DOCS-12966): Updating behavior for countDocuments on empty collections
Branch: v4.0
https://github.com/mongodb/docs/commit/68bbcf715bc77f94822c3a12966b7f118cbc3009

Comment by Githook User [ 10/Oct/19 ]

Author:

{'username': 'jeff-allen-mongo', 'email': 'jeffrey.allen@10gen.com', 'name': 'jeff-allen-mongo'}

Message: (DOCS-12966): Updating behavior for countDocuments on empty collections
Branch: v4.2.1
https://github.com/mongodb/docs/commit/57ff21137b37ef22ceab971b012ddea368cd372d

Comment by Githook User [ 05/Oct/19 ]

Author:

{'name': 'jeff-allen-mongo', 'username': 'jeff-allen-mongo', 'email': 'jeffrey.allen@10gen.com'}

Message: (DOCS-12966): Updating behavior for countDocuments on empty collections
Branch: v4.0.13
https://github.com/mongodb/docs/commit/94703579628a8e72673e75b06e03aee91c267625

Comment by Githook User [ 04/Oct/19 ]

Author:

{'name': 'jeff-allen-mongo', 'username': 'jeff-allen-mongo', 'email': 'jeffrey.allen@10gen.com'}

Message: (DOCS-12966): Updating behavior for countDocuments on empty collections
Branch: v4.2.1
https://github.com/mongodb/docs/commit/31c7b2c4c7e899061b1756c18d4fa846dc945fa2

Generated at Thu Feb 08 08:06:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.