DEV Community

Discussion on: Need a little help here.

Collapse
 
louy2 profile image
Yufan Lou • Edited

This is old but just putting this out there:

If you don't want to deal with ORM or GraphQL, and just need a quick start, then just do

npm i tedious sequelize sql-template-string

tedious is the low-level library for connecting to MSSQL, while sequelize offers a nice interface and supports sql-template-string.

You can then just do this:

const Sequelize = require('sequelize');
const sql = require('sql-template-string');
const sequelize = new Sequelize('database', 'username', 'password', {
  dialect: 'mssql',
  dialectOptions: {
    options: {
      useUTC: false,
      dateFirst: 1,
    }
  }
})

async function main() {
  const [results, metadata] = await sequelize.query(sql`SELECT 1`);
}

main();