wasmcloud-actor-graphdb

Crates.iowasmcloud-actor-graphdb
lib.rswasmcloud-actor-graphdb
version0.1.3
sourcesrc
created_at2021-02-10 19:50:14.466834
updated_at2021-04-16 15:54:03.265517
descriptionGraphDB Actor Interface for wasmCloud Actors
homepage
repositoryhttps://github.com/wasmCloud/actor-interfaces
max_upload_size
id353365
size29,016
wasmCloud Automation Bot (wasmcloud-automation)

documentation

https://docs.rs/wasmcloud-actor-graphdb

README

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:

use serde_json::json;
extern crate wapc_guest as guest;
use wasmcloud_actor_graphdb as graph;
use graph::*;
use wasmcloud_actor_http_server as http;
use wasmcloud_actor_core as actor;

use guest::prelude::*;

#[actor::init]
pub fn init() {
    http::Handlers::register_handle_request(handle_http_request);
}

fn handle_http_request(_: http::Request) -> HandlerResult<http::Response> {
    // Replace `query_db` with `graph::default().query_graph()`
    let (name, birth_year): (String, u32) = query_db(
        "MotoGP".to_string(),
        "MATCH (r:Rider)-[:rides]->(t:Team) WHERE t.name = 'Yamaha' RETURN r.name, r.birth_year"
            .to_string(),
    )?;

    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"))
}

Commit count: 0

cargo fmt