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

Method limit

packages/sql/src/query/QueryBuilder.ts:1990–1999  ·  view source on GitHub ↗

* Sets a LIMIT clause to restrict the number of results. * * @example * ```ts * qb.select('*').limit(10); // First 10 results * qb.select('*').limit(10, 20); // 10 results starting from offset 20 * ```

(limit?: number, offset = 0)

Source from the content-addressed store, hash-verified

1988 * ```
1989 */
1990 limit(limit?: number, offset = 0): SelectQueryBuilder<Entity, RootAlias, Hint, Context, RawAliases, Fields, CTEs> {
1991 this.ensureNotFinalized();
1992 this.#state.limit = limit;
1993
1994 if (offset) {
1995 this.offset(offset);
1996 }
1997
1998 return this as SelectQueryBuilder<Entity, RootAlias, Hint, Context, RawAliases, Fields, CTEs>;
1999 }
2000
2001 /**
2002 * Sets an OFFSET clause to skip a number of results.

Callers 15

executeMethod · 0.95
getSingleResultMethod · 0.95
_findMethod · 0.45
getNativeQueryMethod · 0.45
getCountMethod · 0.45
wrapPaginateSubQueryMethod · 0.45
wrapPaginateSubQueryMethod · 0.45

Calls 2

ensureNotFinalizedMethod · 0.95
offsetMethod · 0.95

Tested by

no test coverage detected