MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / count

Method count

packages/mongodb/src/MongoDriver.ts:301–320  ·  view source on GitHub ↗
(
    entityName: EntityName<T>,
    where: FilterQuery<T>,
    options: CountOptions<T> = {},
  )

Source from the content-addressed store, hash-verified

299 }
300
301 async count<T extends object>(
302 entityName: EntityName<T>,
303 where: FilterQuery<T>,
304 options: CountOptions<T> = {},
305 ): Promise<number> {
306 /* v8 ignore next */
307 if (this.metadata.find(entityName)?.virtual) {
308 return this.countVirtual(entityName, where, options);
309 }
310
311 where = this.renameFields(entityName, where as T, true);
312 const queryOpts = this.buildQueryOptions(options);
313 return this.rethrow(
314 this.getConnection('read').countDocuments(entityName, where as object, {
315 ctx: options.ctx,
316 loggerContext: options.logging,
317 ...queryOpts,
318 }),
319 );
320 }
321
322 async nativeInsert<T extends object>(
323 entityName: EntityName<T>,

Callers

nothing calls this directly

Calls 6

renameFieldsMethod · 0.95
buildQueryOptionsMethod · 0.95
rethrowMethod · 0.80
countDocumentsMethod · 0.80
findMethod · 0.65
getConnectionMethod · 0.65

Tested by

no test coverage detected