I have the following query which uses a mixture of cypher and py2neo ogm. Is it possible to move the where clause into purely py2neo ogm syntax.
FeedItem.match(graph).where("(_)-[:SOURCE]->(:Feed {url:\"%s\"})"%feed.url)
In the documentation for match there do seem to be other options inside the match query. The example uses labels but there is also predicates which lead me to try something like the following:
FeedItem.match(graph,predicates=[RelatedTo(feed, "SOURCE")])
From https://py2neo.org/2021.0/ogm/index.html:
class py2neo.ogm.ModelMatch(graph, labels=frozenset({}), predicates=(), order_by=(), skip=None, limit=None)
The relationship can be added in the Model object.
from py2neo.ogm import Model, Property, RelatedFrom
class Feed(Model):
name = Property("name")
url = Property("url")
subscribers = RelatedFrom("User", "SUBSCRIBED")
items = RelatedFrom("FeedItem", "SOURCE")
Then the query can be simplified from:
FeedItem.match(graph).where("(_)-[:SOURCE]->(:Feed {url:\"%s\"})"%feed.url)
to
feed.items