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:
Client Initialization
- 🦀 Rust
- 🐍 Python
- 📘 TypeScript
- 📦 JavaScript
- 🟣 Kotlin
- 🔷 Go
use ekodb_client::Client;
let client = Client::builder()
.base_url("https://your-subdomain.production.google.ekodb.net")
.api_key("your-api-key")
.build()?;
from ekodb_client import Client
client = Client.new(
"https://your-subdomain.production.google.ekodb.net",
"your-api-key"
)
import { EkoDBClient } from "@ekodb/ekodb-client";
const client = new EkoDBClient({
baseURL: "https://your-subdomain.production.google.ekodb.net",
apiKey: "your-api-key"
});
await client.init();
const { EkoDBClient } = require("@ekodb/ekodb-client");
const client = new EkoDBClient({
baseURL: "https://your-subdomain.production.google.ekodb.net",
apiKey: "your-api-key"
});
await client.init();
import io.ekodb.client.EkoDBClient
val client = EkoDBClient.Builder()
.baseUrl("https://your-subdomain.production.google.ekodb.net")
.apiKey("your-api-key")
.build()
import "github.com/ekoDB/ekodb-client-go"
client := ekodb.NewClient(
"https://your-subdomain.production.google.ekodb.net",
"your-api-key",
)
Insert Records
Create new records in a collection:
- 🦀 Rust
- 🐍 Python
- 📘 TypeScript
- 📦 JavaScript
- 🟣 Kotlin
- 🔷 Go
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"));
user = {
"name": "Alice Smith",
"email": "alice@example.com",
"age": 28
}
result = await client.insert("users", user)
print(f"Created user with ID: {result['id']}")
const user = {
name: "Alice Smith",
email: "alice@example.com",
age: 28
};
const result = await client.insert("users", user);
console.log(`Created user with ID: ${result.id}`);
const user = {
name: "Alice Smith",
email: "alice@example.com",
age: 28
};
const result = await client.insert("users", user);
console.log(`Created user with ID: ${result.id}`);
import io.ekodb.client.types.Record
val user = Record.new()
.insert("name", "Alice Smith")
.insert("email", "alice@example.com")
.insert("age", 28)
val result = client.insert("users", user)
println("Created user with ID: ${result["id"]}")
user := map[string]interface{}{
"name": "Alice Smith",
"email": "alice@example.com",
"age": 28,
}
result, err := client.Insert("users", user)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Created user with ID: %s\n", result["id"])
Find Records
Find by ID
- 🦀 Rust
- 🐍 Python
- 📘 TypeScript
- 📦 JavaScript
- 🟣 Kotlin
- 🔷 Go
let user = client.find_by_id("users", "user-id-123").await?;
println!("Found user: {:?}", user);
user = await client.find_by_id("users", "user-id-123")
print(f"Found user: {user}")
const user = await client.findByID("users", "user-id-123");
console.log("Found user:", user);
const user = await client.findByID("users", "user-id-123");
console.log("Found user:", user);
val user = client.findById("users", "user-id-123")
println("Found user: $user")
user, err := client.FindByID("users", "user-id-123")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Found user: %+v\n", user)
Find All Records
- 🦀 Rust
- 🐍 Python
- 📘 TypeScript
- 📦 JavaScript
- 🟣 Kotlin
- 🔷 Go
let users = client.find_all("users").await?;
println!("Found {} users", users.len());
users = await client.find("users", limit=100)
print(f"Found {len(users)} users")
const users = await client.find("users", { limit: 100 });
console.log(`Found ${users.length} users`);
const users = await client.find("users", { limit: 100 });
console.log(`Found ${users.length} users`);
val users = client.find("users", limit = 100)
println("Found ${users.size} users")
users, err := client.Find("users", map[string]interface{}{"limit": 100})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Found %d users\n", len(users))
Update Records
- 🦀 Rust
- 🐍 Python
- 📘 TypeScript
- 📦 JavaScript
- 🟣 Kotlin
- 🔷 Go
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);
updates = {
"age": 29,
"email": "alice.smith@example.com"
}
updated = await client.update("users", "user-id-123", updates)
print(f"Updated user: {updated}")
const updates = {
age: 29,
email: "alice.smith@example.com"
};
const updated = await client.update("users", "user-id-123", updates);
console.log("Updated user:", updated);
const updates = {
age: 29,
email: "alice.smith@example.com"
};
const updated = await client.update("users", "user-id-123", updates);
console.log("Updated user:", updated);
val updates = Record.new()
.insert("age", 29)
.insert("email", "alice.smith@example.com")
val updated = client.update("users", "user-id-123", updates)
println("Updated user: $updated")
updates := map[string]interface{}{
"age": 29,
"email": "alice.smith@example.com",
}
updated, err := client.Update("users", "user-id-123", updates)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Updated user: %+v\n", updated)
Delete Records
- 🦀 Rust
- 🐍 Python
- 📘 TypeScript
- 📦 JavaScript
- 🟣 Kotlin
- 🔷 Go
client.delete("users", "user-id-123").await?;
println!("User deleted successfully");
await client.delete("users", "user-id-123")
print("User deleted successfully")
await client.delete("users", "user-id-123");
console.log("User deleted successfully");
await client.delete("users", "user-id-123");
console.log("User deleted successfully");
client.delete("users", "user-id-123")
println("User deleted successfully")
err := client.Delete("users", "user-id-123")
if err != nil {
log.Fatal(err)
}
fmt.Println("User deleted successfully")
Collection Management
List Collections
- 🦀 Rust
- 🐍 Python
- 📘 TypeScript
- 📦 JavaScript
- 🟣 Kotlin
- 🔷 Go
let collections = client.list_collections().await?;
println!("Collections: {:?}", collections);
collections = await client.list_collections()
print(f"Collections: {collections}")
const collections = await client.listCollections();
console.log("Collections:", collections);
const collections = await client.listCollections();
console.log("Collections:", collections);
val collections = client.listCollections()
println("Collections: $collections")
collections, err := client.ListCollections()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Collections: %v\n", collections)
Delete Collection
- 🦀 Rust
- 🐍 Python
- 📘 TypeScript
- 📦 JavaScript
- 🟣 Kotlin
- 🔷 Go
client.delete_collection("old_data").await?;
println!("Collection deleted");
await client.delete_collection("old_data")
print("Collection deleted")
await client.deleteCollection("old_data");
console.log("Collection deleted");
await client.deleteCollection("old_data");
console.log("Collection deleted");
client.deleteCollection("old_data")
println("Collection deleted")
err := client.DeleteCollection("old_data")
if err != nil {
log.Fatal(err)
}
fmt.Println("Collection deleted")
Complete Examples
For complete, runnable examples with error handling and advanced features, visit:
📚 Example Repository
The repository contains 77 client library examples organized by language:
- Rust Examples - 14 examples including CRUD, queries, search, batch operations
- Python Examples - 14 examples with async/await patterns
- TypeScript Examples - 14 examples for Node.js and browsers
- Go Examples - 14 examples with idiomatic Go patterns
- Kotlin Examples - 14 examples with coroutines
- JavaScript Examples - 7 examples for Node.js
Featured Examples
- 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
- More Examples - Query builder, search, batch operations, and more
- API Reference - Direct HTTP API documentation
- Authentication - Learn about API keys and permissions
Need Help?
- 📧 Email: support@ekodb.io
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions