Transform your database operations into intelligent, searchable stories in just one API call
# Single operation logging ✨
curl -X POST "http://localhost:3001/api/crud-logger/log" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"operation": "create",
"tableName": "users",
"data": {
"name": "John Doe",
"email": "john@example.com",
"role": "developer"
},
"metadata": {
"connectionId": "64f9b8c7d4e5f6a7b8c9d0e1"
}
}'
# ✅ Auto-generates: "New user 'John Doe' was created on 9/11/2025, 2:30:45 PM with role: developer"
Smart Message Generation
Automatically converts your raw data into human-readable stories perfect for AI search and analytics
/api/crud-logger/log
Log a single CRUD operation with automatic intelligent message generation
/api/crud-logger/log-batch
Log multiple CRUD operations efficiently (up to 100 operations)
/api/crud-logger/search
Search through logged operations using vector similarity and natural language
/api/crud-logger/stats
Get comprehensive usage statistics and insights for your logged operations
Parameter | Type | Required | Description |
---|---|---|---|
operation | string | ✅ | CRUD operation: "create", "read", "update", "delete" |
tableName | string | ✅ | Name of the database table |
data | object | ❌ | Data being operated on |
recordId | string/number | ❌ | ID of the record being operated on |
metadata | object | ❌ | Additional metadata (connectionId, etc.) |
customMessage | string | ❌ | Custom human-readable message (overrides auto-generation) |
Parameter | Type | Required | Description |
---|---|---|---|
query | string | ✅ | Search query for semantic search |
limit | number | ❌ | Number of results to return (default: 10) |
filters | object | ❌ | Additional filters (operation, tableName, etc.) |
includeMetadata | boolean | ❌ | Include metadata in response (default: true) |
const axios = require('axios');
// Log a user creation
async function logUserCreation(userData) {
try {
const response = await axios.post('http://localhost:3001/api/crud-logger/log', {
operation: 'create',
tableName: 'users',
data: userData,
metadata: {
connectionId: '64f9b8c7d4e5f6a7b8c9d0e1',
source: 'user-registration'
}
}, {
headers: {
'Authorization': `Bearer ${YOUR_JWT_TOKEN}`,
'Content-Type': 'application/json'
}
});
console.log('Log created:', response.data);
// Output: User "John Doe" was created on 9/11/2025, 2:30:45 PM with role: developer
} catch (error) {
console.error('Logging failed:', error.response?.data);
}
}
// Search logs
async function searchLogs(searchQuery) {
try {
const response = await axios.post('http://localhost:3001/api/crud-logger/search', {
query: searchQuery,
limit: 20,
filters: {
operation: 'create',
tableName: 'users'
}
}, {
headers: {
'Authorization': `Bearer ${YOUR_JWT_TOKEN}`,
'Content-Type': 'application/json'
}
});
console.log('Search results:', response.data.results);
} catch (error) {
console.error('Search failed:', error.response?.data);
}
}
import requests
import json
def log_crud_operation(operation, table_name, data, jwt_token, metadata=None):
"""Log a CRUD operation to VecTrail"""
url = "http://localhost:3001/api/crud-logger/log"
payload = {
"operation": operation,
"tableName": table_name,
"data": data,
"metadata": metadata or {}
}
headers = {
"Authorization": f"Bearer {jwt_token}",
"Content-Type": "application/json"
}
try:
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
result = response.json()
print(f"✅ Logged: {result['humanMessage']}")
return result
except requests.exceptions.RequestException as e:
print(f"❌ Logging failed: {e}")
return None
# Example usage
user_data = {
"name": "Alice Johnson",
"email": "alice@example.com",
"department": "Engineering"
}
log_crud_operation(
operation="create",
table_name="employees",
data=user_data,
jwt_token="your-jwt-token-here",
metadata={"source": "hr-system"}
)
<?php
function logCrudOperation($operation, $tableName, $data, $jwtToken, $metadata = []) {
$url = "http://localhost:3001/api/crud-logger/log";
$payload = [
'operation' => $operation,
'tableName' => $tableName,
'data' => $data,
'metadata' => $metadata
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Bearer ' . $jwtToken
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 201) {
$result = json_decode($response, true);
echo "✅ Logged: " . $result['humanMessage'] . "\n";
return $result;
} else {
echo "❌ Logging failed: " . $response . "\n";
return null;
}
}
// Example usage
$productData = [
'name' => 'Wireless Headphones',
'price' => 99.99,
'category' => 'Electronics'
];
logCrudOperation('create', 'products', $productData, 'your-jwt-token');
?>
The CRUD Logger automatically generates human-readable messages based on your operation type and data. Here are some examples:
{ operation: "create", tableName: "users", data: { name: "John Doe", email: "john@example.com", role: "developer" } }
{ operation: "update", tableName: "products", data: { name: "iPhone 15", price: 999 }, recordId: "123" }
{ operation: "delete", tableName: "orders", data: { orderId: "ORD-123" } }
{ operation: "read", tableName: "customers", data: { status: "active", location: "NYC" } }
Track user behavior, database changes, and system activities for business intelligence.
Maintain detailed logs of who did what and when for compliance and security.
Use vector search to find patterns and trends in your operational data.
Power conversational interfaces with contextual information from your logs.
Quickly search and identify issues in your application's data flow.
Understand user interactions and optimize their experience.
All CRUD Logger API endpoints require JWT authentication:
Authorization: Bearer YOUR_JWT_TOKEN
Note: Each user can only access their own logs. The system automatically filters results by user ID for security.
🚀 Ready to start logging your CRUD operations intelligently?
Made with ❤️ for developers who love clean, searchable data