-
Notifications
You must be signed in to change notification settings - Fork 232
Match API
Robin Edwards edited this page Jan 29, 2014
·
21 revisions
(Used to be called traverse()
)
class Address(StructuredNode):
name = StringProperty()
street = StringProperty()
town = StringProperty()
post_code = StringProperty()
class Car(StructuredNode):
model = StringProperty(unique_index=True)
class User(StructuredNode):
name = StringProperty(unique_index=True)
age = IntegerProperty()
friend = Relationship(Address, 'FRIEND', ZeroOrMore)
address = Relationship(Address, 'ADDRESS', ZeroOrOne)
car = Relationship(Address, 'CAR', ZeroOrOne)
Matching relationships:
jim.match_friends() # all friends
jim.match_friends(since__gt=yesterday()) # rel property since is greater than yesterday
Filtering nodes returned in a match
jim.match_friends().where(name="Suzan")
# where statement acts on last matched node?
jim.match_friends(since__gt=yesterday()).where(age__gt=2)
Must have or must not have a relationship:
jim.match_friends().has_a('address').has_no('car')
.filter() and .exclude() # rather than where()
User.where(age__lt=16)
or perhaps
User.match(age__lt=16)
User.match.filter(age__lt=16).exclude(age__gt=18)```
Do we want filter and exclude?