Skip to main content

execute_query

Function execute_query 

Source
pub fn execute_query(
    db: &Db,
    query: &AnalyticsQuery,
) -> Result<AnalyticsResult, DbError>
Expand description

Execute an analytics query against the database and return the result.

Steps:

  1. Record the start time (for execution_time_ms).
  2. Fetch all documents from the requested collection (O(n) copy).
  3. Filter documents using the WHERE clause (if provided).
  4. Compute the requested metric over the filtered documents.
  5. Return the result with timing metadata.

ยงArguments

  • db โ€” The database handle. Used to call db.get_all(collection).
  • query โ€” The parsed analytics query (collection + metric + optional filter).