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

Function find

packages/sql/src/AbstractSqlDriver.ts:253–277  ·  view source on GitHub ↗
(
    entityName: EntityName<T>,
    where: ObjectQuery<T>,
    options: FindOptions<T, P, F, E> = {},
  )

Source from the content-addressed store, hash-verified

251 }
252
253 async find<T extends object, P extends string = never, F extends string = never, E extends string = never>(
254 entityName: EntityName<T>,
255 where: ObjectQuery<T>,
256 options: FindOptions<T, P, F, E> = {},
257 ): Promise<EntityData<T>[]> {
258 options = { populate: [], orderBy: [], ...options };
259 const meta = this.metadata.get(entityName);
260
261 if (meta.virtual) {
262 return this.findVirtual<T>(entityName, where, options);
263 }
264
265 if (options.unionWhere?.length) {
266 where = await this.applyUnionWhere(meta, where, options);
267 }
268
269 const qb = await this.createQueryBuilderFromOptions(meta, where, options);
270 const result = await this.rethrow(qb.execute('all'));
271
272 if (options.last && !options.first) {
273 result.reverse();
274 }
275
276 return result;
277 }
278
279 async findOne<T extends object, P extends string = never, F extends string = never, E extends string = never>(
280 entityName: EntityName<T>,

Callers

nothing calls this directly

Calls 4

rethrowMethod · 0.80
getMethod · 0.65
findVirtualMethod · 0.65
executeMethod · 0.65

Tested by

no test coverage detected