New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sql-template-strings-ts

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-template-strings-ts

Functional wrapper for sql-template-strings: ES6 tagged template strings for prepared statements with MySQL and PostgreSQL

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
94
decreased by-10.48%
Maintainers
1
Weekly downloads
 
Created
Source

Functional wrapper for sql-template-strings module. The goal of this library is to expose a pipe friendly API.

Install

$ npm i sql-template-strings sql-template-strings-ts

Documentation

t

declare const t: (strings: TemplateStringsArray, ...values: unknown[]) => SQLStatement

The template string tag.

Example:

import * as SQL from 'sql-template-strings-ts'
import { pipe } from 'fp-ts/function'

declare const book: string
declare const author: string
const query = SQL.t`
  SELECT author FROM books
  WHERE name = ${book} AND author = ${author}`

append

declare const append: (statement: SQLStatement | string | number) => (sql: SQLStatement) => SQLStatement

Appends a string or another statement.

Example:

import * as SQL from 'sql-template-strings-ts'
import { identity, pipe } from 'fp-ts/function'

declare const name: string | undefined
declare const offset: number
const query = pipe(
  SQL.t`SELECT * FROM books`,
  name ? SQL.append(SQL.t` WHERE name = ${name}`) : identity,
  SQL.append(SQL.t` LIMIT 10 OFFSET ${offset}`),
) 

setName

declare const setName: (name: string) => (sql: SQLStatement) => SQLStatement

Sets the name property of this statement for prepared statements in PostgreSQL.

useBind

declare const useBind: (bind: boolean) => (sql: SQLStatement) => SQLStatement

Use a prepared statement with Sequelize. Makes query return a query with $n syntax instead of ? and switches the values key name to bind.


Please refer to sql-template-strings documentation for further details.

Keywords

FAQs

Package last updated on 01 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc