-
-
Notifications
You must be signed in to change notification settings - Fork 1
table.delete()
Oxford Harrison edited this page Nov 19, 2024
·
10 revisions
Programmatically perform a DELETE
query.
See related ➞
DELETE
table.delete(
spec: DeleteSpec | Callback,
): Promise<DeleteResult>;
Param | Interfaces | Description |
---|---|---|
spec |
DeleteSpec |
The delete spec. Can be Callback —a callback function that recieves the underlying DeleteStatement instance for manipulation. |
interface DeleteSpec {
where?: WhereClause;
returning?: Field[];
}
Param | Interfaces | Description |
---|---|---|
where? |
WhereClause |
An optional WHERE clause. |
returning? |
Field |
Optional list of fields to return from the deleted records. |
type DeleteResult = number | Array<object> | object;
Type | Interfaces | Description |
---|---|---|
number |
- | The default delete result—a number indicating the number of records deleted. |
Array<object> |
- | The default delete result when a RETURNING clause is specified—an array of objects representing the deleted records. |
object |
- | The delete result when a RETURNING clause is specified in combination with a find-one condition—an object representing the deleted record. |
Delete all records:
await table.delete( { where: true });
See more ➞
DELETE
Find by ID—with actual ID name automatically figured by Linked QL:
await table.select({ where: 4 });
Return the just deleted records (array):
const deletedRecords = await table.delete({
where: { eq: ['email', { value: 'johndoe@example.com' }] },
returning: '*'
});
Return the just deleted record (object):
const deletedRecord = await table.delete({
where: 4,
returning: '*'
});