Skip to content
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

Question: using custom ids #202

Open
skc11 opened this issue Apr 13, 2024 · 4 comments
Open

Question: using custom ids #202

skc11 opened this issue Apr 13, 2024 · 4 comments

Comments

@skc11
Copy link

skc11 commented Apr 13, 2024

Hi, is there a way to set our own Id property for vertices and edges when creating them ?

@andreclaudino
Copy link

I need the same feature. Tryied passing ~id property and upsert with coalesce (could not implement because I can't underst how to use coalesce), but look like it is not possible to use a custom id.

@Ech0riginal
Copy link

I do not believe TinkerPop3 has this ability out of the box. You can reference each Step here.

I did find that JanusGraph has the ability to store custom vertex IDs, here's the relevant documentation.

@criminosis
Copy link
Contributor

criminosis commented Jul 2, 2024

I've had success doing it to JanusGraph via an anonymous traversal like inside a coalesce

g.V("custom_vertex_id").fold().coalesce::<Vertex, _>([__.unfold(),
__.add_v("some_label_here")
.property(gremlin_client::structure::T::Id, custom_vertex_id)])

But it doesn't seem like you can do on a traversal directly. If you try to do something like:
graph.get_traversal().add_v("some_label_here").property(gremlin_client::structure::T::Id, custom_vertex_id) you fight the type system.

@wolf4ood The property() method there has a hard type requirement that key be &str, whereas the property() for an anonymous traversal (__ returns a TraversalBuilder) takes a key of type Into<GValue>. Not sure if that's intentional?

@criminosis
Copy link
Contributor

I took a stab at adding custom id support in my fork's branch. They're featured in this PR if anyone wants to try the branch until it gets merged & release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants