Skip to content

A simple yet secure and powerful utility function for composing SQL queries in JavaScript or TypeScript.

License

Notifications You must be signed in to change notification settings

NikosTsompanides/sequel-tag

Repository files navigation

sequel-tag

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

sequel-tag is a simple yet secure and powerful utility function for composing SQL queries in JavaScript or TypeScript.

Features

  • Easy SQL Query Composition: Compose SQL queries using template literals and parameterized values effortlessly.
  • Flexible Parameter Handling: Pass a variety of parameter types, including strings, numbers, booleans, dates, null, undefined, and even objects!
  • SQL Injection Prevention: Safeguard your queries against SQL injection attacks with built-in parameterization.
  • TypeScript Support: Enjoy seamless integration with TypeScript, complete with type safety and intelligent autocompletion.
  • Debugging Made Fun: Log or inspect the generated SQL script along with parameter values for easy debugging and troubleshooting.

Install

npm install sequel-tag

Usage

import { sql } from 'sequel-tag';

const id = 1
const name = 'John Doe'
const department = 'IT'

sql`INSERT INTO users (id, name, department) VALUES (${id}, ${name}, ${department})`;
//=> {text: "INSERT INTO users (id, name, department) VALUES ($1, $2, $3)", values: [1, 'John Doe', 'IT']}

About

A simple yet secure and powerful utility function for composing SQL queries in JavaScript or TypeScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published