MCPcopy
hub / github.com/mongodb/node-mongodb-native / count

Method count

src/cursor/find_cursor.ts:151–166  ·  view source on GitHub ↗

* Get the count of documents for this cursor * @deprecated Use `collection.estimatedDocumentCount` or `collection.countDocuments` instead

(options?: CountOptions)

Source from the content-addressed store, hash-verified

149 * @deprecated Use `collection.estimatedDocumentCount` or `collection.countDocuments` instead
150 */
151 async count(options?: CountOptions): Promise<number> {
152 emitWarningOnce(
153 'cursor.count is deprecated and will be removed in the next major version, please use `collection.estimatedDocumentCount` or `collection.countDocuments` instead '
154 );
155 if (typeof options === 'boolean') {
156 throw new MongoInvalidArgumentError('Invalid first parameter to count');
157 }
158 return await executeOperation(
159 this.client,
160 new CountOperation(this.namespace, this.cursorFilter, {
161 ...this.findOptions, // NOTE: order matters here, we may need to refine this
162 ...this.cursorOptions,
163 ...options
164 })
165 );
166 }
167
168 /** Execute the explain for the cursor */
169 async explain(): Promise<Document>;

Callers

nothing calls this directly

Calls 2

emitWarningOnceFunction · 0.90
executeOperationFunction · 0.90

Tested by

no test coverage detected