Liking cljdoc? Tell your friends :D

clojureql.core


*debug*clj

source

build-joinclj

(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
sourceraw docstring

casecljmacro

(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")])
sourceraw docstring

close-globalclj

(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.
sourceraw docstring

compilecljmultimethod

source

declare-tablescljmacro

(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
    ({....} {...})
sourceraw docstring

distinctclj

(distinct obj & args)

A distinct which works on both tables and collections

A distinct which works on both tables and collections
sourceraw docstring

dropclj

(drop obj & args)

A drop which works on both tables and collections

A drop which works on both tables and collections
sourceraw docstring

global-connectionsclj

source

interpolate-sqlclj

(interpolate-sql [stmt & args])
source

open-globalclj

(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.
sourceraw docstring

pickclj

(pick table kw)
source

predicate-symbolsclj

source

Relationcljprotocol

aggregateclj

(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]))

modifyclj

(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)

unionclj

(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!clj

(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-ifclj

(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))

joinclj

(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)))

selectclj

(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-joinclj

(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!clj

(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!clj

(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}]

intersectionclj

(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))

groupedclj

(grouped this field)

Internal: Groups the expression by field

Internal: Groups the expression by field

transformclj

(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 %))

limitclj

(limit this n)

Internal: Queries the table with LIMIT n, call via take

Internal: Queries the table with LIMIT n, call via take

offsetclj

(offset this n)

Internal: Queries the table with OFFSET n, call via drop

Internal: Queries the table with OFFSET n, call via drop

renameclj

(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-onclj

(apply-on this f)

Internal: Applies f on a resultset, call via with-results

Internal: Applies f on a resultset, call via with-results

projectclj

(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])

differenceclj

(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-byclj

(order-by this fields)

Internal: Orders the query by fields, call via sort

Internal: Orders the query by fields, call via sort

update!clj

(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})
source

RTableclj

source

sortclj

(sort obj & args)

A sort which works on both tables and collections

A sort which works on both tables and collections
sourceraw docstring

tableclj

(table table-name)
(table connection-info table-name)

Constructs a relational object.

Constructs a relational object.
sourceraw docstring

table?clj

(table? tinstance)

Returns true if tinstance is an instnce of RTable

Returns true if tinstance is an instnce of RTable
sourceraw docstring

takeclj

(take obj & args)

A take which works on both tables and collections

A take which works on both tables and collections
sourceraw docstring

wherecljmacro

(where clause)
source

with-cnxcljmacro

(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
sourceraw docstring

with-cnx*clj

(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
sourceraw docstring

with-resultscljmacro

(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))
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close