Version: v0.7.1 - Beta.  We welcome contributors & feedback.

Db.deleteRows

Db.deleteRows($table, $whereMapOrSql) -> false

Description

Delete one or more rows from a table, if they exist.

$whereMapOrSql can be a Map of column-to-value constraints, or a SQL TypeString.

// Delete posts by user #123
Db.deleteRows('posts', { userId: 123 })

// Runs query:
// DELETE FROM posts WHERE userID = 123

// Operator in key
$oneYearAgo = Date.create('1 year ago')
Db.deleteRows('posts', { 'postDate <': $oneYearAgo })

// With SQL TypeString
$where = sql'postDate < {}'.fill($oneYearAgo)
Db.deleteRows('posts', $where)

See Also