on-internet
← Community

Node.js: Import .sql file and use it in query

Stack Overflow ·

I'm currently using an ORM for Node, this has worked fairly well in most cases but for more complex applicants I still need to occasionally write SQL. Luckily my ORM has a way to execute SQL queries: orm.execute(`SELECT * FROM "Users"`) Ideally I'd rather not write my SQL inline so I was wondering if it's possible to save my SQL query as a .sql file and then import it into a Javascript/Typescript file so it can be used. import sql from '/my_query.sql'; orm.execute(sql) Is this at all possible?

Comments

Sign in or sign up to comment and upvote.

No comments yet.