NenDB Core API
Complete API reference for NenDB core operations including batch processing, graph queries, and data management functions.
Connection Management
CONNECT
Establish a TCP connection to the NenDB server.
Syntax
CONNECT tcp://localhost:6969
Parameters
host
- Server hostname or IPport
- Server port (default: 6969)Returns
Connection handle or error
Batch Operations
BATCH_CREATE_NODES
Create multiple nodes in a single atomic operation.
Syntax
BATCH_CREATE_NODES <NodeType> [ { id: <id>, <property>: <value>, ... }, ... ]
Example
BATCH_CREATE_NODES User [ { id: 1, name: "Alice", email: "alice@example.com", age: 30 }, { id: 2, name: "Bob", email: "bob@example.com", age: 25 }, { id: 3, name: "Charlie", email: "charlie@example.com", age: 35 } ]
Parameters
NodeType
- Type of nodes to createid
- Unique node identifierproperties
- Node properties as key-value pairsPerformance
Optimal batch size: 100-1000 nodes
BATCH_CREATE_EDGES
Create multiple edges between nodes in a single operation.
Syntax
BATCH_CREATE_EDGES <EdgeType> [ { from: <node_id>, to: <node_id>, <property>: <value>, ... }, ... ]
Example
BATCH_CREATE_EDGES Follows [ { from: 1, to: 2, since: "2024-01-01T00:00:00Z", weight: 1.0 }, { from: 2, to: 3, since: "2024-01-02T00:00:00Z", weight: 0.8 }, { from: 1, to: 3, since: "2024-01-03T00:00:00Z", weight: 0.9 } ]
BATCH_UPDATE_NODES
Update properties of multiple nodes atomically.
Example
BATCH_UPDATE_NODES User [ { id: 1, SET: { age: 31, last_login: "2024-01-15T10:30:00Z" } }, { id: 2, SET: { email: "bob.smith@example.com" } } ]
Query Operations
TRAVERSE
Traverse the graph from starting nodes following specified edge types.
Syntax
TRAVERSE FROM <NodeType>(<id_list>) FOLLOW <EdgeType> [DIRECTION <IN|OUT|BOTH>] [DEPTH <min_depth>:<max_depth>] [WHERE <condition>] [LIMIT <count>] [RETURN <fields>]
Basic Traversal
TRAVERSE FROM User(1) FOLLOW Follows LIMIT 10
Multi-hop with Filtering
TRAVERSE FROM User(1,2,3) FOLLOW Follows DIRECTION OUT DEPTH 1:3 WHERE target.age > 25 LIMIT 100 RETURN nodes.id, nodes.name, edges.since
FIND
Find nodes based on property values with optimized indexing.
Example
FIND User WHERE age BETWEEN 25 AND 35 AND email LIKE "%@example.com" ORDER BY name ASC LIMIT 50
Transaction Operations
Transaction Control
NenDB automatically handles transactions for batch operations, but explicit transaction control is available.
Begin Transaction
BEGIN TRANSACTION
Commit
COMMIT
Rollback
ROLLBACK
Performance Monitoring
System Status
Monitor system performance and resource usage.
System Statistics
SHOW STATS
Cache Performance
SHOW CACHE_STATS
Query Performance
EXPLAIN <query>
Response Format
All operations return responses in this format:
{ "status": "success" | "error" | "partial_failure", "operation": "BATCH_CREATE_NODES", "batch_size": 100, "execution_time_ms": 2.34, "results": [ { "index": 0, "success": true, "node_id": 12345, "data": { ... } } ], "metadata": { "cache_hits": 45, "cache_misses": 5, "memory_used_bytes": 4096, "nodes_affected": 100, "edges_affected": 0 }, "error": null }