[DOCS-10401] Docs for SERVER-29620: Add shorthand syntax for retrieving the record count for a collection using the $collStats agg stage Created: 17/Jun/17  Updated: 29/Oct/23  Resolved: 04/Oct/17

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: 3.5.9

Type: Task Priority: Major - P3
Reporter: Emily Hall Assignee: Jonathan DeStefano
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-29620 Add shorthand syntax for retrieving t... Closed
Participants:
Days since reply: 6 years, 18 weeks, 6 days ago
Epic Link: DOCS: 3.6 Server

 Description   

Documentation Request Summary:

This commit adds a new option to the $collStats aggregation stage, allowing the user to get a 'fast count' for the number of records in the given collection. The count value must be an Object.

A more detailed description is located in the design document:
https://docs.google.com/document/d/1kHIQLLZv7ZMlW9aktZ6CIQdC1L8j3_PJxBdUx_q3FcQ/edit#heading=h.wybafdaad3h

Engineering Ticket Description:

The number of documents in a collection can already be retrieved using $collStats in O(1) time—that is, without executing a query to count the total number of documents. However, we would like to provide syntactic sugar in order to make this easy. Specifically, we will add a count option to $collStats:

> db.myColl.aggregate([{$collStats: {count: {}}}]);
{
ns: "test.myColl",
localTime: ISODate("2017-06-02T15:48:46.510Z"),
count: 11
}

This aggregation will return a single document with the ns and localTime fields, just like other $collStats pipelines. The count will be reported in a new field called count.



 Comments   
Comment by Githook User [ 05/Oct/17 ]

Author:

{'email': 'jonathan.destefano@10gen.com', 'name': 'jonathan', 'username': 'jdestefano-mongo'}

Message: DOCS-10401 - Add count to collStats
Branch: master
https://github.com/mongodb/docs/commit/09828bacd35ea9a8bb29fb672a07c7cb77a365bf

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