Data Loss Warning: This operation permanently deletes all documents in the selection.

Syntax

selection.delete() → result

Arguments

No arguments.

Optargs

No optional arguments.

Returns

result
object
Information about the operation.

Behavior

  • Deletes documents from the selection (single document, filtered results, etc.).
  • Can delete multiple documents when applied to a selection that matches multiple documents.
  • If no documents match the selection, no error is thrown and deleted count will be 0.
  • Deleted documents are permanently removed.

Notes & Caveats

  • Delete operations are irreversible - make sure you have backups if needed.

Example

Delete a single document by ID

Delete a specific user by their primary key.
const result = await r.table('users').get('user_123').delete().run(client);

if (result.deleted > 0) {
  console.log('User deleted successfully');
} else {
  console.log('User not found');
}

Delete multiple documents with filter

Delete all inactive users from the system.
const result = await r
  .table('users')
  .filter((doc) => doc.field('status').eq('inactive'))
  .delete()
  .run(client);

console.log(`Deleted ${result.deleted} inactive users`);
  • get - Get a document by primary key
  • getAll - Get multiple documents
  • filter - Filter documents for deletion
  • insert - Insert new documents
  • update - Update existing documents
  • table - Reference a table

Found a typo? Or maybe a broken link? RuloDB is open-source, help us fix it!