Skip to content
Browse files

restructuring

  • Loading branch information...
1 parent d1c747b commit 8b579ce173c2825d19c2c0367b2373cab0b99431 @wilkes committed Apr 15, 2012
Showing with 24 additions and 15 deletions.
  1. +5 −0 src/clj/projected/dev_server.clj
  2. +19 −0 src/clj/projected/event_store.clj
  3. +0 −15 src/clj/projected/models.clj
View
5 src/clj/projected/dev_server.clj
@@ -1,9 +1,14 @@
(ns projected.dev-server
(:use [noir.core :only (defpage)]
+ [korma.db :only (defdb postgres)]
[projected.application-host :only (layout)])
(:require [noir.response :as response]
[noir.server :as server]))
+(defdb dev (postgres {:db "projected"
+ :user "dev"
+ :password ""}))
+
(defpage "/" [] (response/redirect "/development"))
(defpage "/development" [] (layout :development))
(defpage "/production" [] (layout :production))
View
19 src/clj/projected/event_store.clj
@@ -0,0 +1,19 @@
+(ns projected.event-store
+ (:use korma.core))
+
+(defentity aggregates
+ (entity-fields :id :type :version)
+ (has-many event-log {:fk :aggregate_id}))
+
+(defentity event-log
+ (table :eventlog)
+ (entity-fields :data :version)
+ (belongs-to aggregates {:fk :aggregate_id}))
+
+(defn fetch-aggregate [id]
+ (select aggregates
+ (with event-log)
+ (where {:id id})))
+
+(defn save-events [events]
+ (insert event-log (values events)))
View
15 src/clj/projected/models.clj
@@ -1,15 +0,0 @@
-(ns projected.models
- (:use korma.core
- korma.db))
-
-(defdb dev (postgres {:db "projected"
- :user "dev"
- :password ""}))
-
-(defentity aggregates
- (entity-fields :id :type :version))
-
-(defentity event-log
- (table :eventlog)
- (entity-fields :data :version)
- (belongs-to aggregates {:fk :aggregate_id}))

0 comments on commit 8b579ce

Please sign in to comment.
Something went wrong with that request. Please try again.