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

Method insert

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

* Creates an INSERT query with the given data. * * @example * ```ts * await em.createQueryBuilder(User) * .insert({ name: 'John', email: 'john@example.com' }) * .execute(); * * // Bulk insert * await em.createQueryBuilder(User) * .insert([{ name: 'John' }, { name:

(
    data: RequiredEntityData<Entity> | RequiredEntityData<Entity>[],
  )

Source from the content-addressed store, hash-verified

871 * ```
872 */
873 insert(
874 data: RequiredEntityData<Entity> | RequiredEntityData<Entity>[],
875 ): InsertQueryBuilder<Entity, RootAlias, Context> {
876 return this.init(QueryType.INSERT, data) as unknown as InsertQueryBuilder<Entity, RootAlias, Context>;
877 }
878
879 /**
880 * Creates an INSERT ... SELECT query that copies rows from the source query.

Callers

nothing calls this directly

Calls 1

initMethod · 0.95

Tested by

no test coverage detected