Skip to content
Oxford Harrison edited this page Nov 19, 2024 · 10 revisions

DOCSAPITable API


Programmatically perform a DELETE query.

See related ➞ DELETE

Syntax

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.

DeleteSpec

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.

DeleteResult

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.

Usage

Delete all records:

await table.delete( { where: true });

See more ➞ DELETE

Find One

Find by ID—with actual ID name automatically figured by Linked QL:

await table.select({ where: 4 });

Returning Records

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: '*'
});
Clone this wiki locally