yuppiechef / macaron Goto Github PK
View Code? Open in Web Editor NEWA way to declaratively describe your database model and get going without much fuss.
A way to declaratively describe your database model and get going without much fuss.
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.
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.
(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.
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}))
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'.
Should sync fail?
What is the actual response of the database?
Never tested this case, make sure it works correctly
For example :
(defentity user
"This is a user of the system"
...)
This should generate the CRUD functions incorporating the doc string.
The mysql errors usually don't give the full story
Allow entity to be delete by id or appropriate values.
so that you can write:
(defentity item
(queries
:summary ["SELECT " fields " FROM " tables])
Instead of
(defentity item
(queries
:summary (str "SELECT " fields " FROM " tables))
If :
(defentity test
(fields
[status :enum ["Open" "Closed"]]))
changes to
(defentity test
(fields
[status :enum ["Open" "Started" "Closed"]]))
macaron needs to update the status enum and add the extra state.
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.
Need to make it so that it inspects the existing column and only run an ALTER if there are actual changes
SQLite support would be useful so that you can use this to quickly get going on light projects that need a database.
For a specific column or columns, create a unique index.
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.
JDBC supports timeouts per prepared statements, this might be useful to expose more easily.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.