Luminus

来自开放百科 - 灰狐
2016年5月13日 (五) 02:51Allen (讨论 | 贡献)的版本

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转到: 导航, 搜索

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)

图集

链接

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱