欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2/Agda, C++/Lisp/Haskell
Luminus
来自开放百科 - 灰狐
(版本间的差异)
(以“Luminus 是一个 Clojure 的开源(MIT)微框架。 ==指南== $ lein new luminus my-app $ cd my-app $ lein run Started server on port 3000 http://localho...”为内容创建页面) |
小 (→指南) |
||
| (未显示1个用户的7个中间版本) | |||
| 第2行: | 第2行: | ||
==指南== | ==指南== | ||
| − | $ lein new luminus my-app | + | $ lein new luminus my-app |
$ cd my-app | $ cd my-app | ||
$ lein run | $ lein run | ||
Started server on port 3000 | Started server on port 3000 | ||
http://localhost:3000/ | http://localhost:3000/ | ||
| + | $ lein new luminus app +auth +cljs +postgres | ||
| + | 支持的选项还有:+sqlite, +site, +jetty, +service, +sassc, +swagger, +war, +http-kit, +cucumber, +aleph, +mongodb [http://docs.huihoo.com/luminus/luminusweb.net/docs/profiles.md More Profiles >>>] | ||
| + | |||
| + | 创建 app_dev和app_test数据库,修改 profiles.clj | ||
| + | {:profiles/dev {:env {:database-url "jdbc:postgresql://localhost/app_dev?user=clojure&password=clojure"}} | ||
| + | :profiles/test {:env {:database-url "jdbc:postgresql://localhost/app_test?user=clojure&password=clojure"}}} | ||
| + | 创建数据库,注意:这里要定义 pool-spec 和 db-spec 两种数据库规范 | ||
| + | lein run migrate | ||
| + | lein run | ||
| + | http://localhost:3000/ | ||
| + | 启动 ClojureScript | ||
| + | lein figwheel | ||
| + | cljs.user=> | ||
| + | http://localhost:3000 | ||
| + | 通过 [https://github.com/luminus-framework/conman conman] 完成对数据库连接的管理,使用 [https://github.com/tolitius/mount mount] 管理生命周期,先使用 Korma 对 PostgreSQL 进行操作。 | ||
| + | lein repl | ||
| + | (use 'korma.db) | ||
| + | (defdb db (postgres {:db "mydb" :user "user" :password "dbpass"})) | ||
| + | (insert users (values {:id "huihoo" :first_name "Allen" :last_name "Long" :email "[email protected]" :pass "huihoo"})) | ||
| + | (use 'korma.core) | ||
| + | (defentity users) | ||
| + | (select users) | ||
==图集== | ==图集== | ||
| 第16行: | 第38行: | ||
*[http://www.luminusweb.net/ Luminus官网] | *[http://www.luminusweb.net/ Luminus官网] | ||
*[https://github.com/luminus-framework Luminus @ GitHub] | *[https://github.com/luminus-framework Luminus @ GitHub] | ||
| + | *[http://docs.huihoo.com/luminus/luminusweb.net/docs/useful_libraries.md Luminus Useful Libraries] | ||
| + | *[http://docs.huihoo.com/luminus/luminusweb.net/ Luminus文档] | ||
[[category:framework]] | [[category:framework]] | ||
[[category:clojure]] | [[category:clojure]] | ||
2016年5月13日 (五) 02:51的最后版本
Luminus 是一个 Clojure 的开源(MIT)微框架。
[编辑] 指南
$ lein new luminus my-app $ cd my-app $ lein run Started server on port 3000 http://localhost:3000/ $ lein new luminus app +auth +cljs +postgres
支持的选项还有:+sqlite, +site, +jetty, +service, +sassc, +swagger, +war, +http-kit, +cucumber, +aleph, +mongodb More Profiles >>>
创建 app_dev和app_test数据库,修改 profiles.clj
{:profiles/dev {:env {:database-url "jdbc:postgresql://localhost/app_dev?user=clojure&password=clojure"}}
:profiles/test {:env {:database-url "jdbc:postgresql://localhost/app_test?user=clojure&password=clojure"}}}
创建数据库,注意:这里要定义 pool-spec 和 db-spec 两种数据库规范
lein run migrate lein run http://localhost:3000/
启动 ClojureScript
lein figwheel cljs.user=> http://localhost:3000
通过 conman 完成对数据库连接的管理,使用 mount 管理生命周期,先使用 Korma 对 PostgreSQL 进行操作。
lein repl
(use 'korma.db)
(defdb db (postgres {:db "mydb" :user "user" :password "dbpass"}))
(insert users (values {:id "huihoo" :first_name "Allen" :last_name "Long" :email "[email protected]" :pass "huihoo"}))
(use 'korma.core)
(defentity users)
(select users)
[编辑] 图集
[编辑] 链接
分享您的观点