(! rel name)
!
selects an attribute from a relation.
Example: (! t "id") corresponds to SQL "t.id".
`!` selects an attribute from a relation. Example: (! t "id") corresponds to SQL "t.id".
($avg aref)
Aggregation. Calculates average of column aref
.
Aggregation. Calculates average of column `aref`.
Aggregation. Calculate average of whole relation (AVG(*)
).
Aggregation. Calculate average of whole relation (`AVG(*)`).
($count aref)
Aggregation. Count column aref
.
Aggregation. Count column `aref`.
Aggregation. Count whole relation (COUNT(*)
).
Aggregation. Count whole relation (`COUNT(*)`).
($max aref)
Aggretation. Calculates maximum of column aref
.
Aggretation. Calculates maximum of column `aref`.
Aggregation. Calculate maximum of whole relation (MAX(*)
).
Aggregation. Calculate maximum of whole relation (`MAX(*)`).
($min aref)
Aggregation. Calculates minimum of column aref
.
Aggregation. Calculates minimum of column `aref`.
Aggregation. Calculate minimum of whole relation (MIN(*)
).
Aggregation. Calculate minimum of whole relation (`MIN(*)`).
Aggregation. Calculate standart deviation of whole relation (STDEV(*)
).
Aggregation. Calculate standart deviation of whole relation (`STDEV(*)`).
Aggregation. Sum up whole relation (SUM(*)
).
Aggregation. Sum up whole relation (`SUM(*)`).
Aggregation. Calculate variance of whole relation (VAR(*)
).
Aggregation. Calculate variance of whole relation (`VAR(*)`).
(<- q)
Embed a RA query into the current query.
Embed a RA query into the current query.
(aggregate aggregation-op & attribute)
aggregate
takes an aggregation-operator (:count, :avg, etc.) an optionally
an sqlosure.relational-algebra/attribute-ref
and returns an aggregation.
If no attribute
is provided, returns an aggregation on the whole relation,
otherwise on the specified attribute.
`aggregate` takes an aggregation-operator (:count, :avg, etc.) an optionally an `sqlosure.relational-algebra/attribute-ref` and returns an aggregation. If no `attribute` is provided, returns an aggregation on the whole relation, otherwise on the specified attribute.
(db-connect db-spec backend)
db-connect
takes a connection map and returns a db-connection
-record for
that backend. Dispatches on the :classname
key in db-spec
.
`db-connect` takes a connection map and returns a `db-connection`-record for that backend. Dispatches on the `:classname` key in `db-spec`.
distinct!
is used to define queries that only return distinct rows.
Will result in a DISTINCT
clause in the resulting SQL.
`distinct!` is used to define queries that only return distinct rows. Will result in a `DISTINCT` clause in the resulting SQL.
(group! alist)
Group by specified seq of column references [rel name]
.
Example
(query [t (<- embed t-table)]
(group [t "some_field"])
Group by specified seq of column references `[rel name]`. Example (query [t (<- embed t-table)] (group [t "some_field"])
(order! alist)
(order! attr direction & more-orders)
Takes an alist of [[attribute-ref] :descending/:ascending] to order the result by this attribute.
Example: (query [t (embed t-table)] (order {(! t "foo") :ascending}) (project {"foo" (! t "foo")}))
The corresponding SQL statemant would be "SELECT foo FROM t ORDER BY foo ASC".
Takes an alist of [[attribute-ref] :descending/:ascending] to order the result by this attribute. Example: (query [t (embed t-table)] (order {(! t "foo") :ascending}) (project {"foo" (! t "foo")})) The corresponding SQL statemant would be "SELECT foo FROM t ORDER BY foo ASC".
(project alist-or-relation)
(project project-name project-field & more-projections)
Project some columns of the current query. Returns the resulting state.
Example: (query [t (<- embed t-table)] (project {"foo" (! t "foo") "bar" (! t "bar"))
The corresponding SQL statemant would be "SELECT foo, bar FROM t".
Project some columns of the current query. Returns the resulting state. Example: (query [t (<- embed t-table)] (project {"foo" (! t "foo") "bar" (! t "bar")) The corresponding SQL statemant would be "SELECT foo, bar FROM t".
(put-query q & {:keys [optimize?]})
put-query
takes a (relational algebra) query and returns it's (SQL-) string
representation. Uses the default printer from sqlosure.sql-put
.
`put-query` takes a (relational algebra) query and returns it's (SQL-) string representation. Uses the default printer from `sqlosure.sql-put`.
(query & ?forms)
query
takes a series of relational algebra statements (projection,
selection, grouping, etc.) and returns an executable relational algebra query.
The last statement must be a monadic return (either return or projection).
`query` takes a series of relational algebra statements (projection, selection, grouping, etc.) and returns an executable relational algebra query. The last statement must be a monadic return (either return or projection).
(restrict! expr)
Restrict the current query by a condition.
expr -> query(nil)
Note this doesn't return anything.
Restrict the current query by a condition. expr -> query(nil) Note this doesn't return anything.
(restrict-outer! expr)
Restrict outer part of the current query by a condition.
expr -> query(nil)
Note: this is a monadic action that doesn't return anything.
Restrict outer part of the current query by a condition. expr -> query(nil) Note: this is a monadic action that doesn't return anything.
(restricted! expr)
Restrict the current query by a condition. Returns the resulting state.
Example: (query [t (<- embed t-table)] (restricted t ($<= (! t "id") ($integer 1))
The corresponding SQL statement would be "SELECT <all cols of t> FROM t WHERE id <= 1"
relation expr -> query(relation).
Restrict the current query by a condition. Returns the resulting state. Example: (query [t (<- embed t-table)] (restricted t ($<= (! t "id") ($integer 1)) The corresponding SQL statement would be "SELECT <all cols of t> FROM t WHERE id <= 1" relation expr -> query(relation).
(table sql-name map & opts)
Returns a sqlosure.relational-algebra/base-relation
.
sql-name
ist the name of the table in the DBMS, map
is a map of column-name
-> sqlosure.type-type. opts
may contain a :universe key and a universe
(defaults to nil
).
Returns a `sqlosure.relational-algebra/base-relation`. `sql-name` ist the name of the table in the DBMS, `map` is a map of column-name -> sqlosure.type-type. `opts` may contain a :universe key and a universe (defaults to `nil`).
(top! n)
(top! offset n)
top
is used to define queries that return a cerain number of entries.
When called with one argument n
, top constructs a query that only returns
the first n
elements.
Whan called with two arguments offset
and n
, top constructs a query that
returns the first n
elements with an offset of offset
.
`top` is used to define queries that return a cerain number of entries. When called with one argument `n`, top constructs a query that only returns the first `n` elements. Whan called with two arguments `offset` and `n`, top constructs a query that returns the first `n` elements with an offset of `offset`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close