Query

A file containing the implementation of the Query and Condition classes for filtering and querying data

class lightdb.query.Condition(field: Field, op: str, value: Any)[source]

Bases: object

A class representing a condition in a database query

evaluate(model: MODEL) bool[source]

Evaluate the condition for a given model

Params:

model (Model): The model to evaluate the condition against

Returns:

bool: True if the condition is met, False otherwise

class lightdb.query.Query(model: MODEL)[source]

Bases: object

A class representing a database query

evaluate_conditions(model: MODEL) bool[source]

Evaluate the conditions for a given model

Params:

model (Model): The model to evaluate the conditions against

Returns:

bool: True if all conditions are met, False otherwise

execute() List[MODEL][source]

Execute the query and return the filtered results

Returns:

`List[Model]`: The filtered results of the query

where(*conditions: List[Condition], **filters: Dict[str, Any]) Query[source]

Add a condition to the query

Params:

condition (Condition): The conditions to add to the query

filters (Dict[str, Any]): Keyword arguments representing filter criteria for the model instances

Returns:

Query: The updated query object