Skip to main content

Query

ObjectType Objects

class ObjectType(Enum)

Based on : API description

generate_save_query

def generate_save_query(
obj: BaseModel,
cached: List[str] = None,
source_field: str = None,
index: int = 1,
parent: int = 0) -> Tuple(List[object], List[bytearray], str)

Takes the user model, and builds out a sequence of commands that creates a similar structure on apertureDB's graph.

Arguments:

  • obj BaseModel - The object from the user domain.
  • cached List[str], optional - helps to optimize sending one blob per node. Defaults to None.
  • source_field str, optional - Preserves the relevant connection information from user objects. Defaults to None.
  • index int, optional - The index to start creating references from. Defaults to 1.
  • parent int, optional - The parent of the current node. Defaults to None.

Returns:

tuple : Contains 3 items:

  • List of commands with current node and its children
  • List of blobs with current node and its children
  • index, adjusting the count of children + self for the number of commands in current query

Query Objects

class Query()

This is the underlying class to generate a query using python code.

connected_to

def connected_to(spec: Query, adj_to: int = 0) -> Query

Can be used to connect two commands together, for non trivial queries. This is the lower level function to create a query.

Arguments:

  • spec Query - One command of the query.
  • adj_to int, optional - The command to refer to. Defaults to 0.

Returns:

  • Query - The completed, connected query.

command_properties

def command_properties(prop: str = "") -> List[str]

Helper function to get the properties of all commands the query.

Arguments:

  • v str, optional - description. Defaults to "".

Returns:

  • List[str] - Properties from commands in the order they should be executed.

spec

@classmethod
def spec(cls,
constraints: Constraints = None,
operations: Operations = None,
with_class: str = "",
limit: int = -1,
sort: Sort = None,
list: List[str] = None,
group_by_src: bool = False,
blobs: bool = False) -> Query

The specification for a command to be used in a query.

Arguments:

  • constraints Constraints, optional - Constraints . Defaults to None.
  • with_class ObjectType, optional - description. Defaults to ObjectType.CUSTOM.
  • limit int, optional - description. Defaults to -1.
  • sort Sort, optional - description. Defaults to None.
  • list List[str], optional - description. Defaults to None.

Returns:

  • Query - The query object.