Guides
Queries & CRUD
Create, read, update, delete operations
Create, read, update, and delete nodes with the high-level API. The examples use the user schema from the quick start.
Creating nodes
TypeScript
// Create a single node with returningconst 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 keyconst user = db.get('user', 'alice');// Get by node IDconst userById = db.getById(alice.id);// Check if existsconst exists = db.exists(alice.id);// List all nodes of a typeconst allUsers = db.all('user');// Count nodesconst userCount = db.countNodes('user');Updating data
TypeScript
// Update by key. The update builder's methods return void,// so call them on the builder rather than chaining.const rename = db.update('user', 'alice');rename.set('name', 'Alice C.');rename.execute();// Update multiple propertiesconst edit = db.update('user', 'alice');edit.setAll({ name: 'Alice Chen', email: 'newemail@example.com' });edit.execute();// Remove a propertyconst clear = db.update('user', 'alice');clear.unset('email');clear.execute();Deleting data
TypeScript
// Delete by node IDdb.deleteById(alice.id);// Delete by keydb.deleteByKey('user', 'alice');Next steps
- Graph traversal: follow edges between nodes
- Transactions: commit several writes atomically