Getting connected vertex details and edge details from a known vertex

82 views Asked by At

I have created class in pyorient ogm

class Movie(Node):
    element_plural = "Movies"
    title = String(mandatory=True,indexed=True)
    rating = Short()
class Person(Node):
    element_plural = "Person"
    name = String(mandatory=True,indexed=True)
class ACTS_IN(Relationship):
    element_plural = "ACTS"
    name = String()
    out_ = Link(linked_to=Person,mandatory=True)
    in_ = Link(linked_to=Movie,mandatory=True)
class PRODUCED(Relationship):
    element_plural = "Producers"
    out_ = Link(linked_to=Person,mandatory=True)
    in_ = Link(linked_to=Movie,mandatory=True)

How to I return all details of a particular Movie with actors and producers. Should i call multiple queries for getting details of movie, actors and producers?

Select * from Movie where title='Test'

select expand(ine()).in() from Movie where title = 'Test'

Will it not work as for foreign key?

2

There are 2 answers

1
Michela Bonizzi On

Try this:

select title, in("ACTS_IN").name as actors, in("PRODUCED").name as producers from Movie where title= "Test"


Hope it helps

Regards

0
Ganesh Karewad On

If you are using orient DB 3.0 or greater version use following query to get details of a vertex and connected vertex

select *, ACTS_IN:{*} as actorDetails, PRODUCED:{*} as producerDetailss from Movie where title= "Test"