crates.io  Rust license  documentation

wasmCloud GraphDB Actor Interface

This crate provides an abstraction over the wasmcloud:graphdb contract. This allows actors to interact with a graph database, such as RedisGraph or Neo4j.

Example:

```rust use serdejson::json; extern crate wapcguest as guest; use wasmcloudactorgraphdb as graph; use graph::*; use wasmcloudactorhttpserver as http; use wasmcloudactor_core as actor;

use guest::prelude::*;

[actor::init]

pub fn init() { http::Handlers::registerhandlerequest(handlehttprequest); }

fn handlehttprequest(: http::Request) -> HandlerResulthttp::Response { // Replace query_db with graph::default().query_graph() let (name, birthyear): (String, u32) = querydb( "MotoGP".tostring(), "MATCH (r:Rider)-[:rides]->(t:Team) WHERE t.name = 'Yamaha' RETURN r.name, r.birthyear" .tostring(), )?;

assert_eq!(name, "Alice Rider".to_string());
assert_eq!(birth_year, 1985);

let result = json!({
    "name": name,
    "birth_year": birth_year
});

Ok(http::Response::json(result, 200, "OK"))

}

```