Options
All
  • Public
  • Public/Protected
  • All
Menu

sqigil

Index

Variables

Const rawType

rawType: keyof symbol = Symbol.for('ctf.rawType')

pg-promise compatible symbol for indicating that the results of a toPostgres method should be interpreted as raw/safe.

Const sql

sql: SqlSigil = makeSigil({convertDate: dateToStringUTC,convertObject: JSON.stringify,})

The default SQL template string sigil.

  • Converts dates to UTC format
  • Converts objects to JSON
  • Converts all other values according to usual rules

See SqlSigil for more documentation.

Const toPostgres

toPostgres: keyof symbol = Symbol.for('ctf.toPostgres')

pg-promise compatible symbol for converting values to Postgres. If an object has this attribute, the results of this function will be be taken to be the object's database representation.

Functions

bool

csids

  • csids(ids: Array<string | string[]>): SafeString

csv

dateToString

  • dateToString(date: Date): string
  • Converts a Date object to a Postgres-compatible date string in the local timezone. The resulting string is not wrapped or escaped.

    Parameters

    • date: Date

      the date to convert

    Returns string

    Postgres-compatible date string

dateToStringUTC

  • dateToStringUTC(date: Date): string
  • Converts a Date object to a Postgres-compatible date string in the UTC timezone. The resulting string is not wrapped or escaped.

    Parameters

    • date: Date

      the date to convert

    Returns string

    Postgres-compatible date string in UTC timezone

id

keys

makeSafeString

  • Builds a SafeString object given an assumed-safe string. The resulting object can also be toStringd to return its raw contents.

    Parameters

    • val: string

      the string to wrap

    Returns SafeString

    a SafeString object

makeSigil

  • Builds a sigil/templating object given the provided options

    Parameters

    Returns SqlSigil

    a template-string sigil function

raw

templateSql

  • templateSql(opts: ConversionOpts, strings: TemplateStringsArray, args: unknown[]): string

toLiteral

  • Converts a given value to its Postgres literal representation, given the provided options.

    Parameters

    • opts: ConversionOpts

      the conversion options

    • val: unknown

      the value to convert

    Returns string

    the given value converted to a sql-safe string

tz

utc

value

values

Generated using TypeDoc