Skip to main content
Version: Next

sql

Callable

  • sql<R>(sql, ...values): R

  • 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)`]: [] });

    // with type parameter for assignment without casting
    entity.date = sql<Date>`now()`;

    Parameters

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

    Returns R

Index

Methods

lower

  • lower<R, T>(key): R
  • Parameters

    • key: string | (alias) => string

      Returns R

    now

    ref

    upper

    • upper<R, T>(key): R
    • Parameters

      • key: string | (alias) => string

        Returns R

      Page Options