File tree Expand file tree Collapse file tree 5 files changed +31
-9
lines changed
Expand file tree Collapse file tree 5 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,12 @@ read_only = false
1515
1616[database .surrealdb ]
1717# Example SurrealDB configuration (uncomment to use)
18- # connection = "file ://data/surrealdb/graph.db"
18+ # connection = "ws ://localhost:8000" # Standard SurrealDB WebSocket connection
1919# namespace = "codegraph"
2020# database = "graph"
2121# auto_migrate = true
2222# strict_mode = false
23+ # Alternative: file://data/surrealdb/graph.db for embedded mode
2324
2425# Deprecated: Legacy rocksdb configuration (use database.rocksdb instead)
2526# This is kept for backward compatibility
Original file line number Diff line number Diff line change @@ -12,12 +12,12 @@ read_only = false
1212# SurrealDB configuration
1313[database .surrealdb ]
1414# Connection string options:
15- # - Local file: "file://data/graph.db"
15+ # - WebSocket (default): "ws://localhost:8000"
16+ # - Local file: "file://data/surrealdb/graph.db"
1617# - Memory (testing): "mem://"
1718# - Remote HTTP: "http://localhost:8000"
1819# - Remote HTTPS: "https://example.com:8000"
19- # - WebSocket: "ws://localhost:8000"
20- connection = " file://data/surrealdb/graph.db"
20+ connection = " ws://localhost:8000"
2121
2222# Namespace for multi-tenancy (default: "codegraph")
2323namespace = " codegraph"
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ impl SurrealDbConfig {
9696impl Default for SurrealDbConfig {
9797 fn default ( ) -> Self {
9898 Self {
99- connection : "file ://data/graph.db " . into ( ) ,
99+ connection : "ws ://localhost:8000 " . into ( ) ,
100100 namespace : Self :: default_namespace ( ) ,
101101 database : Self :: default_database ( ) ,
102102 username : None ,
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ pub struct SurrealDbConfig {
3737impl Default for SurrealDbConfig {
3838 fn default ( ) -> Self {
3939 Self {
40- connection : "file ://data/graph.db " . to_string ( ) ,
40+ connection : "ws ://localhost:8000 " . to_string ( ) ,
4141 namespace : "codegraph" . to_string ( ) ,
4242 database : "graph" . to_string ( ) ,
4343 username : None ,
Original file line number Diff line number Diff line change @@ -47,14 +47,31 @@ cargo install surrealdb --locked
4747
4848## Configuration
4949
50- ### Basic Configuration (File-Based )
50+ ### Basic Configuration (WebSocket - Default )
5151
5252Create a configuration file (e.g., ` config/surrealdb.toml ` ):
5353
5454``` toml
5555[database ]
5656backend = " surrealdb"
5757
58+ [database .surrealdb ]
59+ connection = " ws://localhost:8000" # Standard SurrealDB connection
60+ namespace = " codegraph"
61+ database = " graph"
62+ auto_migrate = true
63+ ```
64+
65+ ** Note:** This requires SurrealDB server running on port 8000 (see "Running SurrealDB Server" below).
66+
67+ ### File-Based Configuration (Embedded)
68+
69+ For embedded/local-only usage without a server:
70+
71+ ``` toml
72+ [database ]
73+ backend = " surrealdb"
74+
5875[database .surrealdb ]
5976connection = " file://data/surrealdb/graph.db"
6077namespace = " codegraph"
@@ -242,9 +259,13 @@ runner.migrate().await?;
242259use codegraph_graph :: surrealdb_storage :: * ;
243260use codegraph_core :: * ;
244261
245- // Initialize storage
262+ // Initialize storage (default: ws://localhost:8000)
263+ let config = SurrealDbConfig :: default ();
264+ let mut storage = SurrealDbStorage :: new (config ). await ? ;
265+
266+ // Or specify custom connection
246267let config = SurrealDbConfig {
247- connection : " file ://data/graph.db " . to_string (),
268+ connection : " ws ://localhost:8000 " . to_string (),
248269 namespace : " codegraph" . to_string (),
249270 database : " graph" . to_string (),
250271 .. Default :: default ()
You can’t perform that action at this time.
0 commit comments