cymple.builder.AnyAvailable
- class cymple.builder.AnyAvailable(query)
Bases:
Call
,CaseWhen
,Create
,Delete
,Limit
,Match
,Merge
,Node
,NodeAfterMerge
,OnCreate
,OnMatch
,OperatorEnd
,OperatorStart
,OrderBy
,Procedure
,QueryStart
,Relation
,RelationAfterMerge
,Remove
,Return
,Set
,SetAfterMerge
,Skip
,Union
,Unwind
,Where
,With
,Yield
A class decorator declares anything is available in the current query.
- __init__(query)
Initialize the query object.
Methods
__init__
(query)Initialize the query object.
call
()Concatenate the "CALL" clause.
case_when
(filters, on_true, on_false, ref_name)Concatenate a CASE WHEN clause to the query, created from a list of given property filters.
create
()Concatenate the "CREATE" clause.
cypher
(cypher_query_str)Concatenate a cypher query string
delete
(ref_name)Concatenate a DELETE clause for a referenced instance from the DB.
detach_delete
(ref_name)Concatenate a DETACH DELETE clause for a referenced instance from the DB.
get
()Get the final query string .
limit
(limitation)Concatenate a limit statement.
match
()Concatenate the "MATCH" clause.
Concatenate the "MATCH" clause.
merge
()Concatenate the "MERGE" clause.
node
([labels, ref_name, properties])Concatenate a graph Node, which may be filtered using any label/s and/or property/properties.
Concatenate the "ON CREATE" clause.
on_match
()Concatenate the "ON MATCH" clause.
Concatenate the "OPERATOR END" clause.
operator_start
(operator[, ref_name, args])Concatenate an operator (e.g. ShortestPath), where its result may be given a name for future reference.
order_by
(sorting_properties[, ascending])Concatenate an order by statement.
procedure
(literal_procedure)Concatenate a literal procedure.
related
([label, ref_name, properties, ...])Concatenate an undirectional (i.e. --) graph Relationship, which may be filtered.
related_from
([label, ref_name, properties, ...])Concatenate a backward (i.e. <--) graph Relationship, which may be filtered.
related_to
([label, ref_name, properties, ...])Concatenate a forward (i.e. -->) graph Relationship, which may be filtered.
remove
(properties)Concatenate a remove by statement.
return_literal
(literal)Concatenate a literal RETURN statement.
return_mapping
(mappings)Concatenate a RETURN statement for multiple objects.
set
(properties[, escape_values])Concatenate a SET clause, using the given properties map.
skip
(skip_count)Concatenate a skip statement.
union
()Combines the results of two or more queries.
Combines the results of two or more queries including duplicates.
unwind
(variables)Concatenate an UNWIND clause, keeping one or more variables given in 'variables' arg.
where
(name, comparison_operator, value, **kwargs)Concatenate a WHERE clause to the query, created as {name} {comparison_operator} {value}.
where_literal
(statement, **kwargs)Concatenate a literal WHERE clause to the query.
where_multiple
(filters[, ...])Concatenate a WHERE clause to the query, created from a list of given property filters.
with_
(variables)Concatenate a WITH clause, keeping one or more variables given in 'variables' arg.
yield_
(mappings)Concatenate a YIELD cluase, to yield a list of Mappings.
- call()
Concatenate the “CALL” clause.
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- case_when(filters: dict, on_true: str, on_false: str, ref_name: str, comparison_operator: str = '=', boolean_operator: str = 'AND', **kwargs)
Concatenate a CASE WHEN clause to the query, created from a list of given property filters.
- Parameters:
filters (dict) – A dict representing the set of properties to be filtered
on_true (str) – The query to run when the predicate is true
on_false (str) – The query to run when the predicate is false
ref_name (str) – The name which is used to refer to the newly filtered object
comparison_operator (str) – A string operator, according to which the comparison between property values is done, e.g. for “=”, we get: property.name = property.value, defaults to “=”
boolean_operator (str) – The boolean operator to apply between predicates, defaults to “AND”
**kwargs –
kwargs
:type **kwargs
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- create()
Concatenate the “CREATE” clause.
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- cypher(cypher_query_str)
Concatenate a cypher query string
- delete(ref_name: str)
Concatenate a DELETE clause for a referenced instance from the DB.
- Parameters:
ref_name (str) – The reference name to be used for the delete operation
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- detach_delete(ref_name: str)
Concatenate a DETACH DELETE clause for a referenced instance from the DB.
- Parameters:
ref_name (str) – The reference name to be used for the delete operation
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- get()
Get the final query string .
- limit(limitation: int | str)
Concatenate a limit statement.
- Parameters:
limitation (Union[int, str]) – A non-negative integer or a string of cypher expression that evaluates to a non-negative integer (as long as it is not referring to any external variables)
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- match()
Concatenate the “MATCH” clause.
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- match_optional()
Concatenate the “MATCH” clause.
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- merge()
Concatenate the “MERGE” clause.
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- node(labels: List[str] | str | None = None, ref_name: str | None = None, properties: dict | None = None, **kwargs)
Concatenate a graph Node, which may be filtered using any label/s and/or property/properties.
- Parameters:
labels (Union[List[str], str]) – The neo4j label (or list of labels) for that node, defaults to None
ref_name (str) – A reference name to be used later in the rest of the query, defaults to None
properties (dict) – A dict representing the set of properties by which the nodes are filtered, defaults to None
**kwargs –
kwargs
:type **kwargs
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- on_create()
Concatenate the “ON CREATE” clause.
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- on_match()
Concatenate the “ON MATCH” clause.
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- operator_end()
Concatenate the “OPERATOR END” clause.
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- operator_start(operator: str, ref_name: str | None = None, args: dict | None = None)
Concatenate an operator (e.g. ShortestPath), where its result may be given a name for future reference.
- Parameters:
operator (str) – The neo4j operator to be used (e.g. ShortestPath)
ref_name (str) – A reference name of the result, to be used later in the rest of the query, defaults to None
args (dict) – A dict of arguments, to be passed to the operator function, defaults to None
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- order_by(sorting_properties: str | List[str], ascending: bool = True)
Concatenate an order by statement.
- Parameters:
sorting_properties (Union[str, List[str]]) – A string or a list of strings representing the properties based on which to sort.
ascending (bool) – Use ascending sorting (if false, uses descending)., defaults to True
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- procedure(literal_procedure: str)
Concatenate a literal procedure.
- Parameters:
literal_procedure (str) – A string that is evaluated to a cypher procedure
- Returns:
A Query object with a query that contains the new clause.
- Return type:
Concatenate an undirectional (i.e. –) graph Relationship, which may be filtered.
- Parameters:
label (str) – The relationship label (type) in the DB, defaults to None
ref_name (str) – A reference name to be used later in the rest of the query, defaults to None
properties (dict) – A dict representing the set of properties by which the relationship is filtered, defaults to None
min_hops (int) – The minimal desired number of hops (set -1 for maximum boundary only), defaults to 1
max_hops (int) – The maximal desired number of hops (set -1 for minimal boundary only), defaults to 1
**kwargs –
kwargs
:type **kwargs
- Returns:
A Query object with a query that contains the new clause.
- Return type:
Concatenate a backward (i.e. <–) graph Relationship, which may be filtered.
- Parameters:
label (str) – The relationship label (type) in the DB, defaults to None
ref_name (str) – A reference name to be used later in the rest of the query, defaults to None
properties (dict) – A dict representing the set of properties by which the relationship is filtered, defaults to {}
min_hops (int) – The minimal desired number of hops (set -1 for maximum boundary only), defaults to 1
max_hops (int) – The maximal desired number of hops (set -1 for minimal boundary only), defaults to 1
**kwargs –
kwargs
:type **kwargs
- Returns:
A Query object with a query that contains the new clause.
- Return type:
Concatenate a forward (i.e. –>) graph Relationship, which may be filtered.
- Parameters:
label (str) – The relationship label (type) in the DB, defaults to None
ref_name (str) – A reference name to be used later in the rest of the query, defaults to None
properties (dict) – A dict representing the set of properties by which the relationship is filtered, defaults to {}
min_hops (int) – The minimal desired number of hops (set -1 for maximum boundary only), defaults to 1
max_hops (int) – The maximal desired number of hops (set -1 for minimal boundary only), defaults to 1
**kwargs –
kwargs
:type **kwargs
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- remove(properties: str | List[str])
Concatenate a remove by statement.
- Parameters:
properties (Union[str, List[str]]) – A string or a list of strings representing the properties to remove.
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- return_literal(literal: str)
Concatenate a literal RETURN statement.
- Parameters:
literal (str) – A Cypher string describing the objects to be returned, referencing name/names which were defined earlier in the query
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- return_mapping(mappings: List[Mapping])
Concatenate a RETURN statement for multiple objects.
- Parameters:
mappings (List[Mapping]) – The mapping (or a list of mappings) of db property names to code names, to be returned
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- set(properties: dict, escape_values: bool = True)
Concatenate a SET clause, using the given properties map.
- Parameters:
properties (dict) – A dict to be used to set the variables with their corresponding values
escape_values (bool) – Determines whether the properties values should be escaped or not, defaults to True
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- skip(skip_count: int | str)
Concatenate a skip statement.
- Parameters:
skip_count (Union[int, str]) – A non-negative integer or a string of cypher expression that evaluates to a non-negative integer (as long as it is not referring to any external variables)
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- union()
Combines the results of two or more queries. Duplicates are removed.
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- union_all()
Combines the results of two or more queries including duplicates.
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- unwind(variables: str)
Concatenate an UNWIND clause, keeping one or more variables given in ‘variables’ arg.
- Parameters:
variables (str) – A string refering to previously obtained variables, comma seperated
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- where(name: str, comparison_operator: str, value: str, **kwargs)
Concatenate a WHERE clause to the query, created as {name} {comparison_operator} {value}. E.g. x = ‘abc’.
- Parameters:
name (str) – The name of the object which is to be used in the comparison
comparison_operator (str) – A string operator, according to which the comparison between compared object and the {value} is done, e.g. for “=”, we get: {name} = {value}
value (str) – The value which is compared against
**kwargs –
kwargs
:type **kwargs
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- where_literal(statement: str, **kwargs)
Concatenate a literal WHERE clause to the query.
- Parameters:
statement (str) – A literal string of the required filter
**kwargs –
kwargs
:type **kwargs
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- where_multiple(filters: dict, comparison_operator: str = '=', boolean_operator: str = ' AND ', **kwargs)
Concatenate a WHERE clause to the query, created from a list of given property filters.
- Parameters:
filters (dict) – A dict representing the set of properties to be filtered
comparison_operator (str) – A string operator, according to which the comparison between property values is done, e.g. for “=”, we get: property.name = property.value, defaults to “=”
boolean_operator (str) – The boolean operator to apply between predicates, defaults to ‘ AND ‘
**kwargs –
kwargs
:type **kwargs
- Returns:
A Query object with a query that contains the new clause.
- Return type:
- with_(variables: str)
Concatenate a WITH clause, keeping one or more variables given in ‘variables’ arg.
- Parameters:
variables (str) – A string refering to previously obtained variables, comma seperated
- Returns:
A Query object with a query that contains the new clause.
- Return type: