mantlebio.types.query.query_builder module#

class mantlebio.types.query.query_builder.QueryBuilder(client)[source]#

Bases: Generic[T]

A generic query builder class for constructing queries to be executed by a QueryableClient.

Parameters:

client (T) – The QueryableClient instance to execute the query.

client#

The QueryableClient instance to execute the query.

Type:

T

query_params#

The dictionary containing the query parameters.

Type:

dict

_add_query_condition(condition)[source]#

Helper method to add a query condition to the query.

Parameters:

condition (str) – The condition to add.

Raises:
_validate_condition(condition)[source]#

Helper method to validate the query condition.

Parameters:

condition (str) – The condition to validate.

Raises:

MantleQueryBuilderError – If the condition format is invalid.

_validate_field(field)[source]#

Helper method to validate the query field.

Parameters:

field (str) – The field to validate.

Raises:

MantleQueryBuilderError – If the field has already been added to the query.

and_(condition)[source]#

Adds an AND condition to the query.

Parameters:

condition (str) – The condition to add.

Examples

>>> query_builder.where("field1=value1").and_("field2=value2")
>>> query_builder.where("props{field1}.string.eq=value1").and_("field2=value2")
Returns:

The QueryBuilder instance.

Return type:

QueryBuilder

Raises:
execute()[source]#

Executes the query and returns the response.

Examples

>>> response = query_builder.where("field1=value1").execute()
>>> response = query_builder.where("field1=value1").and_("field2=value2").execute()
Returns:

The response from executing the query.

Return type:

ListResponse

or_(condition)[source]#

Adds an OR condition to the query.

Parameters:

condition (str) – The condition to add.

Raises:

NotImplementedError – This method is not implemented.

where(condition)[source]#

Adds a WHERE condition to the query.

Parameters:

condition (str) – The condition to add.

Examples

>>> query_builder.where("field1=value1")
>>> query_builder.where("props{field2}.string.eq=value2")
Returns:

The QueryBuilder instance.

Return type:

QueryBuilder

Raises: