Skip to main content

Basic Operations

This guide covers the essential CRUD (Create, Read, Update, Delete) operations using ekoDB client libraries.

tip

For complete, runnable examples, visit the ekoDB Examples Repository. It contains 105 working examples across all languages.

Prerequisites

Before you begin, make sure you have:

  1. Installed the client library
  2. Retrieved your API key

Client Initialization

use ekodb_client::Client;

let client = Client::builder()
.base_url("https://your-subdomain.production.aws.ekodb.io")
.api_key("your-api-key")
.build()?;

Insert Records

Create new records in a collection:

use ekodb_client::Record;

let mut user = Record::new();
user.insert("name", "Alice Smith");
user.insert("email", "alice@example.com");
user.insert("age", 28);

let result = client.insert("users", user).await?;
println!("Created user with ID: {:?}", result.get("id"));

Find Records

Find by ID

let user = client.find_by_id("users", "user-id-123").await?;
println!("Found user: {:?}", user);

Find All Records

let users = client.find_all("users").await?;
println!("Found {} users", users.len());

Update Records

let mut updates = Record::new();
updates.insert("age", 29);
updates.insert("email", "alice.smith@example.com");

let updated = client.update("users", "user-id-123", updates).await?;
println!("Updated user: {:?}", updated);

Delete Records

client.delete("users", "user-id-123").await?;
println!("User deleted successfully");

Collection Management

List Collections

let collections = client.list_collections().await?;
println!("Collections: {:?}", collections);

Delete Collection

client.delete_collection("old_data").await?;
println!("Collection deleted");

Complete Examples

For complete, runnable examples with error handling and advanced features, visit:

📚 Example Repository

ekoDB Client Examples

The repository contains 77 client library examples organized by language:

  • Simple CRUD - Basic create, read, update, delete operations
  • Query Builder - Complex queries with filters, sorting, pagination
  • Batch Operations - Efficient bulk inserts, updates, deletes
  • Search - Full-text search with scoring
  • Schema Management - Define and enforce data schemas
  • WebSocket - Real-time queries and subscriptions
  • TTL - Automatic document expiration
  • Key-Value - Simple key-value store operations

Running Examples

# Clone the repository
git clone https://github.com/ekoDB/ekodb-client.git
cd ekodb-client/examples

# Set up environment
cp .env.example .env
# Edit .env with your API URL and key

# Run all examples
make test-examples

# Run specific language examples
make test-examples-rust
make test-examples-python
make test-examples-typescript
make test-examples-kotlin
make test-examples-javascript

# To run this directly without package installation,
# go to https://github.com/ekoDB/ekodb-client-go
# and use the file path to run the example
make test-examples-go

Next Steps

Need Help?