TypeOrm

Revision as of 10:09, 6 February 2019 by Rasimsen (talk | contribs) (Created page with " Insert using Query Builder You can create INSERT queries using QueryBuilder. Examples: <syntaxhighlight lang="javascript"> import {getConnection} from "typeorm"; await g...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)



Insert using Query Builder You can create INSERT queries using QueryBuilder. Examples:

import {getConnection} from "typeorm";

await getConnection()
    .createQueryBuilder()
    .insert()
    .into(User)
    .values([
        { firstName: "Timber", lastName: "Saw" }, 
        { firstName: "Phantom", lastName: "Lancer" }
     ])
    .execute();

This is the most efficient way in terms of performance to insert rows into your database. You can also perform bulk insertions this way.