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:
- Record the start time (for execution_time_ms).
- Fetch all documents from the requested collection (O(n) copy).
- Filter documents using the WHERE clause (if provided).
- Compute the requested metric over the filtered documents.
- Return the result with timing metadata.
ยงArguments
dbโ The database handle. Used to calldb.get_all(collection).queryโ The parsed analytics query (collection + metric + optional filter).