GraphDatabase

Struct GraphDatabase 

Source
pub struct GraphDatabase { /* private fields */ }
Expand description

Graph database for complex relationship queries

Implementations§

Source§

impl GraphDatabase

Source

pub fn instance_of<V: NapiRaw>(env: Env, value: V) -> Result<bool>

Source§

impl GraphDatabase

Source§

impl GraphDatabase

Source

pub fn new(options: Option<JsGraphOptions>) -> Result<Self>

Create a new graph database

§Example
const db = new GraphDatabase({
  distanceMetric: 'Cosine',
  dimensions: 384
});
Source

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 }
});
Source

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
});
Source

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' }
});
Source

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');
Source

pub fn query_sync(&self, cypher: String) -> Result<JsQueryResult>

Query the graph synchronously

§Example
const results = db.querySync('MATCH (n) RETURN n LIMIT 10');
Source

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
});
Source

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);
Source

pub async fn begin(&self) -> Result<String>

Begin a new transaction

§Example
const txId = await db.begin();
Source

pub async fn commit(&self, tx_id: String) -> Result<()>

Commit a transaction

§Example
await db.commit(txId);
Source

pub async fn rollback(&self, tx_id: String) -> Result<()>

Rollback a transaction

§Example
await db.rollback(txId);
Source

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' }]
});
Source

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);
});
Source

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

Source§

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

Source§

unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>

Safety Read more
Source§

impl FromNapiValue for &GraphDatabase

Source§

unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>

Safety Read more
Source§

fn from_unknown(value: JsUnknown) -> Result<Self, Error>

Source§

impl FromNapiValue for &mut GraphDatabase

Source§

unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>

Safety Read more
Source§

fn from_unknown(value: JsUnknown) -> Result<Self, Error>

Source§

impl ObjectFinalize for GraphDatabase

Source§

fn finalize(self, env: Env) -> Result<(), Error>

Source§

impl ToNapiValue for GraphDatabase

Source§

impl TypeName for &GraphDatabase

Source§

impl TypeName for &mut GraphDatabase

Source§

impl TypeName for GraphDatabase

Source§

impl ValidateNapiValue for &GraphDatabase

Source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

Safety Read more
Source§

impl ValidateNapiValue for &mut GraphDatabase

Source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

Safety Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> JsValuesTupleIntoVec for T
where T: ToNapiValue,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V