Giter VIP home page Giter VIP logo

macaron's People

Stargazers

 avatar  avatar Josh Tilles avatar

Watchers

geoff avatar James Cloos avatar Chris Truter avatar  avatar Steve Porter avatar  avatar Stefan Coetzee avatar Jon Edwards avatar

macaron's Issues

Abstract out the mysql code into mysql.clj

This is to prepare for building support for other database engines, such as sqlite

Keep in mind that the intention of supporting mutliple engines is not about making it easy to switch between engines, but rather that you can implement macaraon on top of your engine of choice. This approach allows us to not have to abstract a query language.

Better error handling in named queries with empty collection parameters

Currently, when you call a named query with a collection parameter, it spits out a nasty sql error because the IN () is empty. If a parameter is a collection but empty, it should info out a warning, but return an empty list. Most of the time if an IN () is empty, it means there shouldn't be any results anyhow.

Create convenience query function for simple listings

(list-user-by :firstname ["John" "Mary"])

should be equivalent (in result, don't have to create an actual named query) to running a named query:

(defentity user
  (fields
    [firstname :varchar])
  (queries
    :list-queries "SELECT * FROM user WHERE firstname IN (:names)"))

(list-user-query :list-queries {:names ["John" "Mary"]})

It should support multiple columns:

(list-user-by :firstname ["John" "Mary"] :group_id [1 2 3 4] :member "admin")

should run the query "SELECT * FROM user WHERE firstname in (?,?) AND group-id IN (?,?,?,?) AND member=?"

Notice the handling of collections - passing a collection should make it an 'in', but passing a single value should make it an =.

This will lead to the creation of more specific named queries, such as reports and joins instead of a lot of utility listing queries, at the tradeoff of not having visibility on all the queries used in the system in one place.

auto-generate named query functions

Currently, one uses

(list-entity-query :group-user {:user-id 0 :group-id 10})

I would like to have macaron generate a function for each named query, with parameters, so in the above case, it would generate the function:

(defn query-entity-group-user [user-id group-id]
  (list-entity-query :group-user {:user-id user-id :group-id group-id}))

Support Datomic

This would mean that named queries become datomic query structures instead of JDBC strings.

Also, use native datomic types - don't try to create mappings for mysql types currently used except for enum, auto-index, version and unique-uuid, which are macaron helper 'types'.

Delete Entity

Allow entity to be delete by id or appropriate values.

Create first-entity-query and single-entity-query functions for each entity

Method signatures:

(defn first-entity-query [query param-map])
(defn single-entity-query [query param-map])

first-entity-query won't mind multiple results where single-entity-query should throw an exception if multiple results are found.

Note: entity is the name of the entity in question (defentity user..) will generate (defn first-user-query [...]) for instance.

Support other SQL dialects

SQLite support would be useful so that you can use this to quickly get going on light projects that need a database.

Remove gensym'd argument names from defentityrecord generated functions

Currently it generates the CRUD functions using gensym'd symbols, which ends up with cryptic looking autocomplete information, for example on the list functions:

([fld__244__auto__ val__2656__auto__])

Not ideal. It should be

([fld val])

The named query function autogeneration works correctly.

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.