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

Method addSelect

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

* Adds fields to an existing SELECT query.

(
    fields: F,
  )

Source from the content-addressed store, hash-verified

809 * Adds fields to an existing SELECT query.
810 */
811 addSelect<const F extends Field<Entity, RootAlias, Context> | readonly Field<Entity, RootAlias, Context>[]>(
812 fields: F,
813 ): SelectQueryBuilder<
814 Entity,
815 RootAlias,
816 Hint,
817 Context,
818 RawAliases | ExtractRawAliases<F extends readonly unknown[] ? F : [F]>,
819 Fields | ExtractRootFields<F extends readonly (infer U)[] ? U & string : F & string, RootAlias, Context>,
820 CTEs
821 > {
822 this.ensureNotFinalized();
823
824 if (this.#state.type && this.#state.type !== QueryType.SELECT) {
825 return this as any;
826 }
827
828 return this.select([...Utils.asArray(this.#state.fields), ...Utils.asArray(fields as string)] as any) as any;
829 }
830
831 distinct(): SelectQueryBuilder<Entity, RootAlias, Hint, Context, RawAliases, Fields, CTEs> {
832 this.ensureNotFinalized();

Callers 1

joinAndSelectMethod · 0.95

Calls 3

ensureNotFinalizedMethod · 0.95
selectMethod · 0.95
asArrayMethod · 0.80

Tested by

no test coverage detected