(build-join dialect {[tname pred] :data type :type pos :position} aliases)
Generates a JOIN statement from the joins field of a table
Generates a JOIN statement from the joins field of a table
(case alias & clauses)
Lets you specify a column using the SQL CASE operator.
The first argument is your alias for the return of CASE, the remaining arguments are a series of conditions and their returns similar to condp. The final two arguments can optionally be ':else value'.
Example: (project (table :t1) [:id (case :wages (<= :wage 5) "low" (>= :wage 10) "high" :else "average")])
Lets you specify a column using the SQL CASE operator. The first argument is your alias for the return of CASE, the remaining arguments are a series of conditions and their returns similar to condp. The final two arguments can optionally be ':else value'. Example: (project (table :t1) [:id (case :wages (<= :wage 5) "low" (>= :wage 10) "high" :else "average")])
(close-global & [conn-name])
Supplied with a keyword identifying a global connection, that connection is closed and the reference dropped. When called without argument, close the default global connection.
Supplied with a keyword identifying a global connection, that connection is closed and the reference dropped. When called without argument, close the default global connection.
(declare-tables conn-info & names)
Given a connection info map (or nil) and as list of tablenames as keywords a number of tables will be (def)ined with identical names of the keywords given.
Ex. (declare-tables db :t1 :t2) @t1 ({....} {...})
Given a connection info map (or nil) and as list of tablenames as keywords a number of tables will be (def)ined with identical names of the keywords given. Ex. (declare-tables db :t1 :t2) @t1 ({....} {...})
(distinct obj & args)
A distinct which works on both tables and collections
A distinct which works on both tables and collections
(drop obj & args)
A drop which works on both tables and collections
A drop which works on both tables and collections
(open-global specs)
(open-global conn-name specs)
Opens a global connection with the supplied specs. If given a conn-name, use it as a key to access that connection, else set the default global connection.
Opens a global connection with the supplied specs. If given a conn-name, use it as a key to access that connection, else set the default global connection.
(aggregate this aggregates)
(aggregate this aggregates group-by)
Selects aggregates from a table. Aggregates are denoted with the :function/field syntax. They can be aliased by supplying a vector [:function/field :as :myfn]. Optionally accepts a group-by argument
Ex. (-> (table :one) (aggregate [[:count/* :as :cnt]] [:id]))
Selects aggregates from a table. Aggregates are denoted with the :function/field syntax. They can be aliased by supplying a vector [:function/field :as :myfn]. Optionally accepts a group-by argument Ex. (-> (table :one) (aggregate [[:count/* :as :cnt]] [:id]))
(modify this modifiers)
Allows for arbitrary modifiers to be applied on the result. Can either be called directly or via helper interfaces like 'distinct'.
Ex. (-> (table :one) (modify "TOP 5")) ; MSSqls special LIMIT syntax (-> (table :one) distinct)
Allows for arbitrary modifiers to be applied on the result. Can either be called directly or via helper interfaces like 'distinct'. Ex. (-> (table :one) (modify "TOP 5")) ; MSSqls special LIMIT syntax (-> (table :one) distinct)
(union this relations)
(union this relations opts)
Selects the union between tables. Mode can take a keyword which can be anything which your backend supports. Commonly :all is used to allow duplicate rows.
Ex. (-> (table :one) (union (table :two) :all))
Selects the union between tables. Mode can take a keyword which can be anything which your backend supports. Commonly :all is used to allow duplicate rows. Ex. (-> (table :one) (union (table :two) :all))
(update-in! this pred record)
Inserts or updates a record where pred is true. Record is a map from strings or keywords (identifying columns) to updated values.
Ex. (update-in! (table :one) (where (= :id 5)) {:age 22})
Inserts or updates a record where pred is true. Record is a map from strings or keywords (identifying columns) to updated values. Ex. (update-in! (table :one) (where (= :id 5)) {:age 22})
(select-if this test predicate)
(select-if this test predicate else)
Evaluates test. If logical true, confines the query to rows for which the predicate is true. Optionally accepts a predicate to confine the query if the test is logical false.
Ex. (select-if (table :users) (nil? s) (where (= :email "default@website.com")) (where (= :email s))
Evaluates test. If logical true, confines the query to rows for which the predicate is true. Optionally accepts a predicate to confine the query if the test is logical false. Ex. (select-if (table :users) (nil? s) (where (= :email "default@website.com")) (where (= :email s))
(join this table2 join_on)
Joins two tables on join_on
Ex. (join (table :one) (table :two) :id) (join (table :one) (table :two) (where (= :one.col :two.col)))
Joins two tables on join_on Ex. (join (table :one) (table :two) :id) (join (table :one) (table :two) (where (= :one.col :two.col)))
(select this predicate)
Confines the query to rows for which the predicate is true
Ex. (select (table :users) (where (= :id 5)))
Confines the query to rows for which the predicate is true Ex. (select (table :users) (where (= :id 5)))
(outer-join this table2 type join_on)
Joins two tables on join_on and sets the direction of the join. type can be :right, :left, :full etc. Backend support may vary.
Ex. (outer-join (table :one) (table :two) :left :id) (outer-join (table :one) (table :two) :left (where (= :one.id :two.id)))
Joins two tables on join_on and sets the direction of the join. type can be :right, :left, :full etc. Backend support may vary. Ex. (outer-join (table :one) (table :two) :left :id) (outer-join (table :one) (table :two) :left (where (= :one.id :two.id)))
(disj! this predicate)
Deletes record(s) from the table
Ex. (disj! (table :one) (where (= :age 22)))
Deletes record(s) from the table Ex. (disj! (table :one) (where (= :age 22)))
(conj! this records)
Inserts record(s) into the table
Ex. (conj! (table :one) {:age 22}) (conj! (table :one) [{:age 22} {:age 23}]
Inserts record(s) into the table Ex. (conj! (table :one) {:age 22}) (conj! (table :one) [{:age 22} {:age 23}]
(intersection this relations)
(intersection this relations opts)
Selects the intersection between tables. Mode can take a keyword which can be anything which your backend supports. Commonly :all is used to allow duplicate rows.
Ex. (-> (table :one) (intersection (table :two) :all))
Selects the intersection between tables. Mode can take a keyword which can be anything which your backend supports. Commonly :all is used to allow duplicate rows. Ex. (-> (table :one) (intersection (table :two) :all))
(grouped this field)
Internal: Groups the expression by field
Internal: Groups the expression by field
(transform this fn)
Transforms results using fn when deref or with-results is called. The pick helper function is implemented using this. Ex. (-> (table :users) (select (where (= :id 5))) (transform #(map :email %))
Transforms results using fn when deref or with-results is called. The pick helper function is implemented using this. Ex. (-> (table :users) (select (where (= :id 5))) (transform #(map :email %))
(limit this n)
Internal: Queries the table with LIMIT n, call via take
Internal: Queries the table with LIMIT n, call via take
(offset this n)
Internal: Queries the table with OFFSET n, call via drop
Internal: Queries the table with OFFSET n, call via drop
(rename this newnames)
Renames colums when joining. Newnames is a map of replacement pairs
Ex. (-> (join (table :one) (table :two) :id) (project [:id]) (rename {:one.id :idx}))
Renames colums when joining. Newnames is a map of replacement pairs Ex. (-> (join (table :one) (table :two) :id) (project [:id]) (rename {:one.id :idx}))
(apply-on this f)
Internal: Applies f on a resultset, call via with-results
Internal: Applies f on a resultset, call via with-results
(project this fields)
Confines the query to the fieldlist supplied in fields
Ex. (project (table :users) [:email])
Confines the query to the fieldlist supplied in fields Ex. (project (table :users) [:email])
(difference this relations)
(difference this relations opts)
Selects the difference between tables. Mode can take a keyword which can be anything which your backend supports. Commonly :all is used to allow duplicate rows.
Ex. (-> (table :one) (difference (table :two) :all))
Selects the difference between tables. Mode can take a keyword which can be anything which your backend supports. Commonly :all is used to allow duplicate rows. Ex. (-> (table :one) (difference (table :two) :all))
(order-by this fields)
Internal: Orders the query by fields, call via sort
Internal: Orders the query by fields, call via sort
(update! this pred record)
Updates a record where pred is true. Record is a map from strings or keywords (identifying columns) to updated values.
Ex. (update! (table :one) (where (= :id 5)) {:age 22})
Updates a record where pred is true. Record is a map from strings or keywords (identifying columns) to updated values. Ex. (update! (table :one) (where (= :id 5)) {:age 22})
(sort obj & args)
A sort which works on both tables and collections
A sort which works on both tables and collections
(table table-name)
(table connection-info table-name)
Constructs a relational object.
Constructs a relational object.
(table? tinstance)
Returns true if tinstance is an instnce of RTable
Returns true if tinstance is an instnce of RTable
(take obj & args)
A take which works on both tables and collections
A take which works on both tables and collections
(with-cnx db-spec & body)
For internal use only. If you want to wrap a query in a connection, use with-connection
For internal use only. If you want to wrap a query in a connection, use with-connection
(with-cnx* con-info func)
Evaluates func in the context of a database connection, with following precedence: Already open connection > connection passed on table > global connection
Evaluates func in the context of a database connection, with following precedence: Already open connection > connection passed on table > global connection
(with-results [results tble] & body)
Executes the body, wherein the results of the query can be accessed via the name supplies as results.
Example: (with-results [res table] (println res))
Executes the body, wherein the results of the query can be accessed via the name supplies as results. Example: (with-results [res table] (println res))
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close