Deleting records

To delete a record you can execute, for example:

const user = await xata.db.Users.delete('rec_cd8s3r8avc42pi67m13g');
// or, using the delete method on the record object:

In case the record with the given ID doesn't exist, the REST API returns a 404 and the TypeScript SDK throws an exception.

Transactions are used when deleting multiple records:

const users = await xata.db.Users.delete(['rec_cd8s3r8avc42pi67m13g', 'rec_cgh9o1oncchhigq95n2g']);

Transactions will not fail a delete operation if no record is found. All operations in a transaction must succeed otherwise it is rolled back.

Now that you have seen how to do the basic create, remove, update, and delete operations, you can check out the docs on using the free text search API, which is a new super power that Xata gives you.

You can also review the pages on getting data, updating data, inserting data. We've got guides for each of these operations.