Relationships

class mogwai.relationships.base.Relationship(edge_class, vertex_class, direction='BOTH', strict=True, gremlin_path=None, vertex_callback=None, edge_callback=None, query_callback=None, create_callback=None)

Define incoming and outgoing relationships that exist. Also enforce schema IN, OUT and BOTH directions

Warn if queries return schema violations.

allowed(edge_type, vertex_type)

Check whether or not the allowed Edge and Vertex type are compatible with the schema defined

Parameters:
  • edge_type – Edge Class
  • vertex_type – Vertex Class
Type:

mogwai.models.Edge

Type:

mogwai.models.Vertex

Return type:

bool

create(*args, **kwargs)

Creates a Relationship defined by the schema

Parameters:
  • edge_params (dict) – (Optional) Parameters passed to the instantiation method of the Edge
  • vertex_params (dict) – (Optional) Parameters passed to the instantiation method
  • edge_type (mogwai.models.Vertex | None) – (Optional) Edge class type, otherwise it defaults to the first Edge type known
  • edge_type – (Optional) Vertex class type, otherwise it defaults to the first Vertex type known
  • callback (method) – (Optional) Callback function to handle results
Return type:

tuple(mogwai.models.Edge, mogwai.models.Vertex) | Object

edges(*args, **kwargs)

Query and return all Edges attached to the current Vertex

TODO: fix this, the instance method isn’t properly setup :param limit: Limit the number of returned results :type limit: int | long :param offset: Query offset of the number of paginated results :type offset: int | long :param callback: (Optional) Callback function to handle results :type callback: method :rtype: List[mogwai.models.Edge] | Object

query(*args, **kwargs)

Generic Query method for quick access

Parameters:
  • edge_types (List[mogwai.models.Edge] | None) – List of Edge classes to query against
  • callback (method) – (Optional) Callback function to handle results
Return type:

mogwai.models.query.Query | Object

vertices(*args, **kwargs)

Query and return all Vertices attached to the current Vertex

TODO: fix this, the instance method isn’t properly setup :param limit: Limit the number of returned results :type limit: int | long :param offset: Query offset of the number of paginated results :type offset: int | long :param callback: (Optional) Callback function to handle results :type callback: method :rtype: List[mogwai.models.Vertex] | Object

mogwai.relationships.base.requires_vertex(method)