All files / src delete.ts

90% Statements 9/10
50% Branches 1/2
100% Functions 1/1
88.88% Lines 8/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2022x 22x 22x     22x 22x       22x 13x             22x  
import fallback from './fallback.js'
import id from './identifier.js'
import line from './line.js'
import type S from './sanitised.js'
import type Sid from './sanitised-identifier.js'
import tsql from './template.js'
import whereOf from './where.js'
 
/** @returns DELETE DML for table with optional WHERE clause. */
export const delete_ =
  (table: Sid | string, where?: S | Record<string, unknown>): S =>
    line(
      tsql`delete from ${id(table)}`,
      where ?
        tsql`where ${fallback(where, whereOf)}` :
        undefined
    )
 
export default delete_