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

Method merge

packages/sql/src/query/QueryBuilder.ts:1945–1958  ·  view source on GitHub ↗
(data?: EntityData<Entity> | readonly string[])

Source from the content-addressed store, hash-verified

1943 merge<const P extends string>(data: readonly NestedAutoPath<Entity, RootAlias, Context, P>[]): this;
1944 merge<F extends Field<Entity, RootAlias, Context>>(data?: EntityData<Entity> | F[]): this;
1945 merge(data?: EntityData<Entity> | readonly string[]): this {
1946 if (!this.#state.onConflict) {
1947 throw new Error('You need to call `qb.onConflict()` first to use `qb.merge()`');
1948 }
1949
1950 if (Array.isArray(data) && data.length === 0) {
1951 return this.ignore();
1952 }
1953
1954 this.#state.onConflict[this.#state.onConflict.length - 1].merge = data as
1955 | EntityData<Entity>
1956 | InternalField<Entity>[];
1957 return this;
1958 }
1959
1960 returning<F extends Field<Entity, RootAlias, Context>>(fields?: F | F[]): this {
1961 this.#state.returning = Utils.asArray(fields as string);

Callers 3

nativeUpdateFunction · 0.45
nativeUpdateManyFunction · 0.45
joinOneToReferenceMethod · 0.45

Calls 1

ignoreMethod · 0.95

Tested by

no test coverage detected