Coder Social home page Coder Social logo

coast-framework / lighthouse Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 2.0 111 KB

Easy clojure relational database queries, migrations and connection pooling

License: MIT License

Makefile 0.21% Clojure 99.79%
clojure sqlite hikari-cp connection-pool datomic-pull-sql datomic sqlite3 postgresql postgres database

lighthouse's People

Contributors

kthu avatar swlkr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lighthouse's Issues

Doc issue with :joins

Hi,
In your example on joins :

(db/q conn '[:select todo/* person/*
:from todo
:joins person/todos])

We get the error

PSQLException ERROR: table name "todo" specified more than once org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse (QueryExecutorImpl.java:2440)

Don't you think it should be simply

(db/q conn '[:select todo/* person/*
:joins person/todos])

?

In addition, it could be useful to have a way to get the real SQL query generated underneath. Would it be possible?

In the same vein, how do you use multiple joins?
E.g.

(def todos-users [{:db/col :person/name :db/type "text" :db/unique? true :db/nil? false}
{:db/col :item/name :db/type "text" :db/unique? true :db/nil? false}
{:db/rel :item/todos :db/type :many :db/ref :todo/item}
{:db/rel :todo/item :db/type :one :db/ref :item/id}
{:db/rel :person/todos :db/type :many :db/ref :todo/person}
{:db/rel :todo/person :db/type :one :db/ref :person/id}
{:db/col :todo/name :db/type "text"}
{:db/col :todo/done :db/type "boolean" :db/default false :db/nil? false}])

(db/migrate conn todos-users)

(db/q conn '[:select todo/* :joins person/todos item/todos])
PSQLException ERROR: table name "todo" specified more than once org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse (QueryExecutorImpl.java:2440)

Thanks

defq function

Hi,

defq as defined is not a macro but a function.
However you use ~ in its body. I saw that when trying to use it unsuccessfully.
Based on your code in https://github.com/coast-framework/coast, something like this works better for me :

(defmacro defq
  ([conn-pool n filename]
   `(let [q-fn# (lighthouse.defq/query-fn ~conn-pool (assoc (lighthouse.defq/query ~(str n) ~filename) :ns *ns*))]
      (lighthouse.defq/create-root-var ~(str n) q-fn#)))
  ([conn-pool filename]
   `(lighthouse.defq/query-fns ~conn-pool ~filename)))

Any opinion on that?

Thanks,
jerome

db/insert return value

Hi, (lighthouse.core/insert conn {:person/name "Gen Eric"}) returns (1) if it succeded. In the readme at insert I found this: "p is auto-resolved to (get p :person/id)". So what do I misunderstand? how can I get back the id of the inserted row? Thank you, appreciating your work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.