module Card::Query

Card::Query is for finding implicit lists (or counts of lists) of cards.

Search and Set cards use Card::Query to query the database, and it’s also frequently used directly in code.

Query “statements” (objects, really) are made in CQL (Card Query Language). Because CQL is used by Sharks, [the primary CQL Syntax documentation is on decko.org](decko.org/CQL_Syntax). Note that the examples there are in JSON, like Search card content, but statements in Card::Query are in ruby form.

In Decko’s current form, Card::Query generates and executes SQL statements. However, the SQL generation is largely (not yet fully) separated from the CQL statement interpretation.

The most common way to use Card::Query is as follows:

list_of_cards = Card::Query.run(statement)

This is equivalent to:

query = Card::Query.new(statement)
list_of_cards = query.run

Upon initiation, the query is interpreted, and the following key objects are populated:

Each condition is either a SQL-ready string (boo) or an Array in this form:

[field_string_or_sym, (Card::Value::Query object)]