I would like to know if there is a feature of TypeORM that supports raw sql queries for Insert Update Delete Select etc..
ORM is good only for developers and maintenance because most developers aren't very good at SQL, but if you're actually talking about performance, SQL completely trumps it.
Raw SQL, sometimes also called native SQL, is the most basic, most low-level form of database interaction. You tell the database what to do in the language of the database. Most developers should know basics of SQL. This means how to CREATE tables and views, how to SELECT and JOIN data, how to UPDATE and DELETE data.
TypeORM is a TypeScript ORM (object-relational mapper) library that makes it easy to link your TypeScript application up to a relational database database. TypeORM supports MySQL, SQlite, Postgres, MS SQL Server, and a host of other traditional options.
According to this issue comment, TypeORM enables you to use any queries to your heart's content. using entityManager.query()
Here is the documentation.
UPDATE
Link above is outdated, try this instead entity-manager-api.
const rawData = await manager.query(`SELECT * FROM USERS`);
2020 UPDATE, entityManager.query() basing the entityManager off the EntityManager class, was not working for me so had to do this:
import { getManager } from 'typeorm'; const entityManager = getManager(); const someQuery = await entityManager.query(` SELECT fw."X", fw."Y", ew.* FROM "table1" as fw JOIN "table2" as ew ON fw."X" = $1 AND ew.id = fw."Y"; `, [param1]);
https://orkhan.gitbook.io/typeorm/docs/working-with-entity-manager
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With