Skip to content
~/docs/guides/queries
DOCUMENTATION

Queries & CRUD

Create, read, update, delete operations

Learn how to create, read, update, and delete data in KiteDB.

Creating Nodes

typescript
// Create a single node with returning
const alice = db.insert('user')
  .values('alice', { name: 'Alice Chen', email: 'alice@example.com' })
  .returning();

// Create without returning (slightly faster)
db.insert('user')
  .values('bob', { name: 'Bob Smith', email: 'bob@example.com' })
  .execute();

Reading Data

typescript
// Get by key
const user = db.get('user', 'alice');

// Get by node ID
const userById = db.getById(alice.id);

// Check if exists
const exists = db.exists(alice.id);

// List all nodes of a type
const allUsers = db.all('user');

// Count nodes
const userCount = db.countNodes('user');

Updating Data

typescript
// Update by key
db.update(user, 'alice')
  .set('name', 'Alice C.')
  .execute();

// Update multiple properties
db.update(user, 'alice')
  .setAll({ name: 'Alice Chen', email: 'newemail@example.com' })
  .execute();

// Remove a property
db.update(user, 'alice')
  .unset('email')
  .execute();

Deleting Data

typescript
// Delete by node ID
db.deleteById(alice.id);

// Delete by key
db.deleteByKey('user', 'alice');

Next Steps