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

How to clone a vertex with edges #553

Closed
danielcweber opened this issue Feb 25, 2022 Discussed in #552 · 5 comments
Closed

How to clone a vertex with edges #553

danielcweber opened this issue Feb 25, 2022 Discussed in #552 · 5 comments

Comments

@danielcweber
Copy link
Contributor

Discussed in #552

Originally posted by rautjris February 25, 2022
Hi !

Need some advice how to clone a Vertex with it's properties and Edges/edge properties to a new Vertex.
I'm newbie with gremlin and using Cosmos Db gremlin.

This is what I have now:

await g.V(sourceid).As((, source) => _
.AddV(new SampleVertex())
.As(( _ , clone) => _
.SideEffect(s =>
{
return s.Select(source).OutE().As(( _ , e) => _
.Select(e).InV().AddE().From(f => f.Select(clone)));
}
)
));

But I'm out of ideas how to copy properties.

Thanks in advance

@github-actions
Copy link
Contributor

Hello @danielcweber,
thanks for your interest in ExRam.Gremlinq. The issue was labelled "How would this look like in raw Gremlin?" because it seems you tried to formulate a query with ExRam.Gremlinq that fails either when constructing or executing the query. This might be a shortcoming or missing feature of ExRam.Gremlinq, however, in this case, it seems that there is not much that ExRam.Gremlinq could do since there is no valid Gremlin that it could construct that would achieve what you intended. In general, or when you feel that it should be possible, the question is: How would this look like in raw Gremlin? If you're new to Gremlin, check out the Tinkerpop reference.

@danielcweber
Copy link
Contributor Author

danielcweber commented Feb 25, 2022

@rautjris For clarification: It seems that you're trying to write a query in Gremlinq when it's unclear how the query could be written in raw Gremlin. Such questions are probably better formed as a question on [https://groups.google.com/g/gremlin-users](the mailing list).

@rautjris
Copy link

rautjris commented Feb 28, 2022

@danielcweber I'm using the ExRam.Gremlinq and trying to do similar "clone a node and it's edges" like in this Stackoverflow post using the ExRam.Gremlinq.
https://stackoverflow.com/questions/51900116/gremlin-clone-a-node-and-its-edges

So I'm selecting the source properties and trying to set those in clone properties.
.Select(clone).Property(p.Value.Key, p.Value.Value)); sounds promising but looks like it is not the way to go.

        var result =  _g.V<SampleVertex>(sourceid).As((_, source) => _
            .AddV<SampleVertex>()
            .As((_, clone) => _
            .SideEffect(s =>
            {
               return s.Select(source).Properties().As((_, p) => _
                .Select(clone).Property(???));
                //what to put here? raw gremlin should be like: property(select('p').key(), select('p').value())).
            }
            )
            .SideEffect(s =>
                    {
                        return s.Select(source).OutE<SampleEdge>().As((_, e) => _
                        .Select(e).InV().AddE<SampleEdge>().From(t => t.Select(clone)));
                    }
                )
            )).Debug();

@danielcweber
Copy link
Contributor Author

danielcweber commented Feb 28, 2022

what to put here? raw gremlin should be like: property(select('p').key(), select('p').value())).

That would surely work well in Gremlin, however, property-overloads that would take traversals for key and value are, as it is now, not part of Gremlinq. It might be implemented in an upcoming release though. PRs, as always, are always appreciated.

@stale
Copy link

stale bot commented Mar 18, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 18, 2022
@stale stale bot closed this as completed Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants