pub struct GraphDatabase { /* private fields */ }Expand description
Graph database for complex relationship queries
Implementations§
Source§impl GraphDatabase
impl GraphDatabase
Source§impl GraphDatabase
impl GraphDatabase
pub fn into_reference( val: GraphDatabase, env: Env, ) -> Result<Reference<GraphDatabase>>
pub fn into_instance(self, env: Env) -> Result<ClassInstance<GraphDatabase>>
Source§impl GraphDatabase
impl GraphDatabase
Sourcepub fn new(options: Option<JsGraphOptions>) -> Result<Self>
pub fn new(options: Option<JsGraphOptions>) -> Result<Self>
Create a new graph database
§Example
const db = new GraphDatabase({
distanceMetric: 'Cosine',
dimensions: 384
});Sourcepub async fn create_node(&self, node: JsNode) -> Result<String>
pub async fn create_node(&self, node: JsNode) -> Result<String>
Create a node in the graph
§Example
const nodeId = await db.createNode({
id: 'node1',
embedding: new Float32Array([1, 2, 3]),
properties: { name: 'Alice', age: 30 }
});Sourcepub async fn create_edge(&self, edge: JsEdge) -> Result<String>
pub async fn create_edge(&self, edge: JsEdge) -> Result<String>
Create an edge between two nodes
§Example
const edgeId = await db.createEdge({
from: 'node1',
to: 'node2',
description: 'knows',
embedding: new Float32Array([0.5, 0.5, 0.5]),
confidence: 0.95
});Sourcepub async fn create_hyperedge(&self, hyperedge: JsHyperedge) -> Result<String>
pub async fn create_hyperedge(&self, hyperedge: JsHyperedge) -> Result<String>
Create a hyperedge connecting multiple nodes
§Example
const hyperedgeId = await db.createHyperedge({
nodes: ['node1', 'node2', 'node3'],
description: 'collaborated_on_project',
embedding: new Float32Array([0.3, 0.6, 0.9]),
confidence: 0.85,
metadata: { project: 'AI Research' }
});Sourcepub async fn query(&self, cypher: String) -> Result<JsQueryResult>
pub async fn query(&self, cypher: String) -> Result<JsQueryResult>
Query the graph using Cypher-like syntax (simplified)
§Example
const results = await db.query('MATCH (n) RETURN n LIMIT 10');Sourcepub fn query_sync(&self, cypher: String) -> Result<JsQueryResult>
pub fn query_sync(&self, cypher: String) -> Result<JsQueryResult>
Sourcepub async fn search_hyperedges(
&self,
query: JsHyperedgeQuery,
) -> Result<Vec<JsHyperedgeResult>>
pub async fn search_hyperedges( &self, query: JsHyperedgeQuery, ) -> Result<Vec<JsHyperedgeResult>>
Search for similar hyperedges
§Example
const results = await db.searchHyperedges({
embedding: new Float32Array([0.5, 0.5, 0.5]),
k: 10
});Sourcepub async fn k_hop_neighbors(
&self,
start_node: String,
k: u32,
) -> Result<Vec<String>>
pub async fn k_hop_neighbors( &self, start_node: String, k: u32, ) -> Result<Vec<String>>
Get k-hop neighbors from a starting node
§Example
const neighbors = await db.kHopNeighbors('node1', 2);Sourcepub async fn batch_insert(&self, batch: JsBatchInsert) -> Result<JsBatchResult>
pub async fn batch_insert(&self, batch: JsBatchInsert) -> Result<JsBatchResult>
Batch insert nodes and edges
§Example
await db.batchInsert({
nodes: [{ id: 'n1', embedding: new Float32Array([1, 2]) }],
edges: [{ from: 'n1', to: 'n2', description: 'knows' }]
});Sourcepub fn subscribe(&self, callback: JsFunction) -> Result<()>
pub fn subscribe(&self, callback: JsFunction) -> Result<()>
Subscribe to graph changes (returns a change stream)
§Example
const unsubscribe = db.subscribe((change) => {
console.log('Graph changed:', change);
});Sourcepub async fn stats(&self) -> Result<JsGraphStats>
pub async fn stats(&self) -> Result<JsGraphStats>
Get graph statistics
§Example
const stats = await db.stats();
console.log(`Nodes: ${stats.totalNodes}, Edges: ${stats.totalEdges}`);Trait Implementations§
Source§impl FromNapiMutRef for GraphDatabase
impl FromNapiMutRef for GraphDatabase
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Safety Read more
Source§impl FromNapiRef for GraphDatabase
impl FromNapiRef for GraphDatabase
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Safety Read more
Source§impl FromNapiValue for &GraphDatabase
impl FromNapiValue for &GraphDatabase
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl FromNapiValue for &mut GraphDatabase
impl FromNapiValue for &mut GraphDatabase
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl ToNapiValue for GraphDatabase
impl ToNapiValue for GraphDatabase
Source§unsafe fn to_napi_value(env: napi_env, val: GraphDatabase) -> Result<napi_value>
unsafe fn to_napi_value(env: napi_env, val: GraphDatabase) -> Result<napi_value>
Safety Read more
Source§impl TypeName for &GraphDatabase
impl TypeName for &GraphDatabase
Source§impl TypeName for &mut GraphDatabase
impl TypeName for &mut GraphDatabase
Source§impl TypeName for GraphDatabase
impl TypeName for GraphDatabase
Source§impl ValidateNapiValue for &GraphDatabase
impl ValidateNapiValue for &GraphDatabase
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Source§impl ValidateNapiValue for &mut GraphDatabase
impl ValidateNapiValue for &mut GraphDatabase
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl Freeze for GraphDatabase
impl RefUnwindSafe for GraphDatabase
impl Send for GraphDatabase
impl Sync for GraphDatabase
impl Unpin for GraphDatabase
impl UnwindSafe for GraphDatabase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more