-
Notifications
You must be signed in to change notification settings - Fork 0
Delete
Christoph Herrmann edited this page Nov 13, 2019
·
6 revisions
The return value is the count of the rows affected by the delete located in result.rowCount
of the pg
result object.
const rowCount = await sql.delete(
'users',
{ name: 'name' }
)
// text: DELETE FROM "users" WHERE "name" = $1
// values: ['name']
table
can also be given as an array with the schema
. Otherwise if it's defined the defaultSchema
option will be used.
For more complex delete queries the SQL Tag can be used.
const name = 'name'
const rowCount = await sql.delete(
sql`
DELETE FROM "users" WHERE "name" = ${name}
`
)
// text: DELETE FROM "users" WHERE "name" = $1
// values: ['name']
Where .delete()
throws an error if no conditions are given, .deleteAll()
comes in place allowing to be called without conditions.
Found a bug or missing a feature? -> Create a new Issue
Found a security issue? -> Look at the Security Policy
Having questions, want to give feedback or talk to me? -> E-Mail me [email protected]