MikroORM and MongoDB

Use aggregation query

Use EntityRepository from the @mikro-orm/mongodb package instead of the @mikro-orm/core package.

 // import { EntityRepository } from '@mikro-orm/core'; import { EntityRepository } from '@mikro-orm/mongodb' ; class User { constructor ( @InjectRepository (User) private readonly userRepository: EntityRepository<User>,  ) {} @Get () find ( ) { return this . userRepository . aggregate ([]); }}

This article is transferred from https://www.wujingquan.com/posts/d0e7837e.html
This site is only for collection, and the copyright belongs to the original author.