Skip to main content
Version: 6.1

sql

Callable

  • sql(sql, ...values): 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