Skip to main content
Version: Next

sql

Callable

  • sql(sql: readonly string[], ...values: unknown[]): any

  • Alternative to the raw() helper allowing to use it as a tagged template function for the simple cases.

    // as a value
    await em.find(User, { time: sql`now()` });

    // as a key
    await em.find(User, { [sql`lower(name)`]: name.toLowerCase() });

    // value can be empty array
    await em.find(User, { [sql`(select 1 = 1)`]: [] });

    Parameters

    • sql: readonly string[]
    • rest...values: unknown[]

    Returns any

Index

Methods

lower

  • lower(key: string | (alias: string) => string): string
  • Parameters

    • key: string | (alias: string) => string

      Returns string

    now

    • now(length?: number): string
    • Parameters

      • optionallength: number

      Returns string

    ref

    upper

    • upper(key: string | (alias: string) => string): string
    • Parameters

      • key: string | (alias: string) => string

        Returns string

      Page Options