-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No exposed ability to grab custom maps from output #108
Comments
+1 please open a pr |
You're right, getting a BoltMap is not possible right now, and there are other Bolt types that are not publicly accessible. Before we're talking about adding a PR for this, I am currently rewriting a lot of the "get" functions to be based on With this change |
Thanks so much for your update, Eagerly waiting for this feat to drop. |
We've just release #[derive(Debug, Deserialize, PartialEq)]
struct Model {
node: Node,
d_left: Option<Node>,
d_right: Option<Node>,
}
// optional if you want to map the row itself, not just the `res` column
#[derive(Deserialize)]
struct Res {
res: Vec<Model>,
}
let model1 = BoltNode::new(BoltInteger::new(1), BoltList::new(), BoltMap::new());
let model2 = BoltNode::new(BoltInteger::new(2), BoltList::new(), BoltMap::new());
let models = HashMap::from_iter([("node", model1), ("d_left", model2)]);
let models = BoltList::from(vec![models.into()]);
let row = Row::new(
vec!["res".into()].into(),
vec![BoltType::List(models)].into(),
);
let m1 = row.get::<Vec<Model>>("res").unwrap();
let m2 = row.to::<Res>().unwrap().res;
assert_eq!(m1, m2);
assert_eq!(m1.len(), 1);
let m = &m1[0];
assert_eq!(m.node.id(), 1);
assert_eq!(m.d_left.as_ref().unwrap().id(), 2);
assert_eq!(m.d_right.as_ref(), None); |
Right now as I see it there is no ability to grab a custom map from the output. This is important when aggregating results using something like
collect
. Specifically, I have code that collects three nodes into a map as below:This result in
res
being aBoltList
ofBoltMap
s. Unfortunately becauseBoltMap
isnt exposed, I cannot unpack this with something likelet maps = row.get::<Vec<BoltMap>>("res").unwrap();
and becauseRow
does not implementFrom<BoltType>
I cannot useRow
either.I have made local changes that include a new exposed type call
Map
that wrapsBoltMap
and a exposes a singleget
method to allow users to use arbitrary output from the graph.If these changes seem reasonable I can create a pull request, or really any feedback on this would be appreciated. Maybe I am missing something already available to do this. Thanks!
The text was updated successfully, but these errors were encountered: