Created
September 7, 2018 20:14
-
-
Save sundarj/5f0ac7e9784e60f6673e8cc4a1f48ce9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
λ boot -d korma repl | |
Retrieving maven-metadata.xml from https://repo.clojars.org/ | |
Retrieving korma-0.5.0-RC1.pom from https://repo.clojars.org/ (4k) | |
Retrieving c3p0-0.9.5.2.pom from https://repo1.maven.org/maven2/ (1k) | |
Retrieving mchange-commons-java-0.2.11.pom from https://repo1.maven.org/maven2/ (3k) | |
Retrieving java.jdbc-0.6.1.pom from https://repo1.maven.org/maven2/ (2k) | |
Retrieving korma-0.5.0-RC1.jar from https://repo.clojars.org/ (21k) | |
Retrieving c3p0-0.9.5.2.jar from https://repo1.maven.org/maven2/ (486k) | |
Retrieving mchange-commons-java-0.2.11.jar from https://repo1.maven.org/maven2/ (592k) | |
Retrieving java.jdbc-0.6.1.jar from https://repo1.maven.org/maven2/ (15k) | |
Retrieving clojure-1.8.0.jar from https://repo1.maven.org/maven2/ (3538k) | |
Classpath conflict: org.clojure/clojure version 1.10.0-alpha7 already loaded, NOT loading version 1.8.0 | |
[WARNING] No nREPL middleware descriptor in metadata of boot.repl$disable_exception_colors@19fede33, see clojure.tools.middleware/set-descriptor! | |
nREPL server started on port 63681 on host 127.0.0.1 - nrepl://127.0.0.1:63681 | |
REPL-y 0.3.7, nREPL 0.2.12 | |
Clojure 1.10.0-alpha7 | |
Java HotSpot(TM) 64-Bit Server VM 1.8.0_144-b01 | |
Exit: Control+D or (exit) or (quit) | |
Commands: (user/help) | |
Docs: (doc function-name-here) | |
(find-doc "part-of-name-here") | |
Find by Name: (find-name "part-of-name-here") | |
Source: (source function-name-here) | |
Javadoc: (javadoc java-object-or-class-here) | |
Examples from clojuredocs.org: [clojuredocs or cdoc] | |
(user/clojuredocs name-here) | |
(user/clojuredocs "ns-here" "name-here") | |
boot.user=> (require 'korma.core) | |
nil | |
boot.user=> (source korma.core/select) | |
(defmacro select | |
"Creates a select query, applies any modifying functions in the body and then | |
executes it. `ent` is either a string or an entity created by defentity. | |
ex: (select user | |
(fields :name :email) | |
(where {:id 2}))" | |
[ent & body] | |
(make-query-then-exec #'select* body ent)) | |
nil | |
boot.user=> (source korma.core/make-query-then-exec) | |
(defn- make-query-then-exec [query-fn-var body & args] | |
`(let [query# (-> (~query-fn-var ~@args) | |
~@body)] | |
(exec query#))) | |
nil | |
boot.user=> (source korma.core/select*) | |
(defn select* | |
"Create a select query with fields provided in Ent. If fields are not provided, | |
create an empty select query. Ent can either be an entity defined by defentity, | |
or a string of the table name" | |
[ent] | |
(let [default-fields (not-empty (:fields ent))] | |
(make-query ent {:type :select | |
:fields (or default-fields [::*]) | |
:from [(:ent this-query)] | |
:modifiers [] | |
:joins [] | |
:where [] | |
:order [] | |
:aliases #{} | |
:group [] | |
:results :results}))) | |
nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment