class Message(Node): title = String() body = String() sender = GQField( 'Person', GraphQuery( 'personGraph', direction='INBOUND' ).f('e._id').like('created/%') ) attachments = GQList( 'Media', query=GraphQuery( 'personGraph', direction='INBOUND' ) ) class Config: indexes = (Index('title'), Index('body', type='fulltext')) @classmethod async def create(cls, _, info, **data): print('create message') pprint(data) return cls(**data)
class ToDo(Node): title = String() creator = GQField( 'Person', GraphQuery( 'personGraph', direction='INBOUND', ).f('e._id').like('created/%') )
class Department(Node): title = String() description = String() infos = GQList( 'Info', query=GraphQuery( 'personGraph', direction='INBOUND' ) ) employees = GQList( 'Person', query=GraphQuery( 'personGraph', direction='INBOUND' ) ) class Config: indexes = (Index('title'),)
class Person(Node): name = String() email = Email() birthday = Date() employer = GQField( 'Department', GraphQuery( 'personGraph', direction='OUTBOUND', ret='{"node": v, "status":e.status}' ), extra={'status': String()} ) friends = GQList( 'Person', GraphQuery( 'personGraph', ret=('{"node": v,' ' "id": e._id, ' ' "status": e.status, ' ' "since": e._created, ' ' "pId": startVertexId' '}') ), extra={ 'id': ID(), 'status': String(), 'since': String(), 'pId': String() } ) messages = GQList( 'Message', GraphQuery( 'personGraph', direction='INBOUND' ).f('e._id').like('received/%') ) class Config: indexes = (Index('email'),)
class Group(Node): title = String() description = String() members = GQList( 'Person', query=GraphQuery( 'personGraph', direction='INBOUND' ) ) class Config: indexes = (Index('title'),)
class Info(Node): title = String() body = String() infos = GQList( 'Info', GraphQuery( 'personGraph', direction='INBOUND' ).f('e._id').like('belongs_to/%') ) class Config: indexes = (Index('title'),)
class Concert(Node): date = Date() status = Field(ConcertStatus, default_value=ConcertStatus.NULL) venue = GQField( 'Venue', GraphQuery( 'personGraph', direction='INBOUND' ) ) class Config: indexes = (Index('date', unique=False),)
class Venue(Node): name = String() city = String() zip_code = String() street = String() concerts = GQList( 'Concert', query=GraphQuery( 'personGraph', direction='INBOUND' )) class Config: indexes = (Index('name', unique=False), Index('city', unique=False))