Registry / database / sql-template-strings-ts

sql-template-strings-ts

JSON →
library1.1.0jsnpmunverified

Functional wrapper around sql-template-strings providing an fp-ts-friendly, pipeable API for building parameterized SQL queries. v1.1.0 is current, with a focus on FP patterns using fp-ts. Requires peer dependencies fp-ts ^2.9.5 and sql-template-strings ^2.2.2. Differentiates from raw sql-template-strings by offering pointfree combinators (append, setName, useBind) for composing queries without imperative statements.

npm install sql-template-strings-ts
INSTALL
IMPORT
SIG · SQL-TEMPLATE-STRIN
S
sql-template-strings-ts
databasejavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

t
✓ import { t } from 'sql-template-strings-ts'
✗ const { t } = require('sql-template-strings-ts')
ESM-only; named export.
SQL module
✓ import * as SQL from 'sql-template-strings-ts'
✗ import SQL from 'sql-template-strings-ts'
No default export; use namespace import.
append
✓ import { append } from 'sql-template-strings-ts'
✗ import { append } from 'sql-template-strings'
append is exported from this package, not from the underlying sql-template-strings.
setName
✓ import { setName } from 'sql-template-strings-ts'
✗ import { setName } from 'sql-template-strings'
setName is specific to this wrapper.
useBind
✓ import { useBind } from 'sql-template-strings-ts'
✗ import { useBind } from 'sql-template-strings'
useBind is from this package.

Demonstrates creating a parameterized SQL query using the t template tag and appending clauses via pipe.

import * as SQL from 'sql-template-strings-ts'; import { pipe } from 'fp-ts/function'; const name = 'Alice'; const limit = 10; const offset = 0; const query = pipe( SQL.t`SELECT * FROM users WHERE name = ${name}`, SQL.append(SQL.t` LIMIT ${limit} OFFSET ${offset}`) ); console.log(query.text); console.log(query.values);
Debug
Known issues
gotchaMust provide only TemplateStringsArray and values to t; passing a variable as first argument will fail.
fix
Use backticks with ${} syntax.
affects: >=1.0.0
breakingBreaking: default export removed in 1.0.0; must use named exports or namespace import.
fix
Switch to `import * as SQL from 'sql-template-strings-ts'`.
affects: >=1.0.0
deprecatedThe sql-template-strings dependency may have breaking changes; always check compatibility.
fix
Ensure sql-template-strings is at ^2.2.2.
affects: *
gotchaappend does not validate SQL; misuse may cause injection if values are not parameterized.
fix
Always use t tag for dynamic values.
affects: *
gotchaError: Cannot find module 'fp-ts' if peer dependency missing.
fix
npm install fp-ts sql-template-strings sql-template-strings-ts
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: t is not a function
Importing t as default instead of named export.
fix
import { t } from 'sql-template-strings-ts'
Cannot find module 'fp-ts'
Peer dependency fp-ts not installed.
fix
npm install fp-ts
Property 'append' does not exist on type 'typeof import(...)'
Importing from 'sql-template-strings' instead of 'sql-template-strings-ts'.
fix
import { append } from 'sql-template-strings-ts'
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
fp-tsrequiredRequired for pipe and functional combinators
sql-template-stringsrequiredCore library providing SQLStatement type and template tag functionality
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources
sql-template-strings-ts — npm install sql-template-strings-ts · libregistry