Browse files

Move insert down near create.

  • Loading branch information...
1 parent 669e85d commit 6c3c1b9f2972908b5edf0d5dd856df6b964f8199 @duelinmarkers committed Jul 23, 2009
Showing with 9 additions and 9 deletions.
  1. +9 −9 src/clj_record/core.clj
View
18 src/clj_record/core.clj
@@ -55,15 +55,6 @@
(sql/transaction
~@body)))
-(defn insert
- "Inserts a record populated with attributes and returns the generated id."
- [model-name attributes]
- (transaction (db-spec-for model-name)
- (let [attributes (run-callbacks attributes model-name :before-save)]
- (sql/insert-values (table-name model-name) (keys attributes) (vals attributes)))
- (sql/with-query-results rows [(id-query-for (db-spec-for model-name) (table-name model-name))]
- (val (first (first rows))))))
-
(defn find-by-sql
"Returns a vector of matching records.
select-query-and-values should be something like
@@ -97,6 +88,15 @@
(or (find-record model-name {:id id})
(throw (IllegalArgumentException. "Record does not exist"))))
+(defn insert
+ "Inserts a record populated with attributes and returns the generated id."
+ [model-name attributes]
+ (transaction (db-spec-for model-name)
+ (let [attributes (run-callbacks attributes model-name :before-save)]
+ (sql/insert-values (table-name model-name) (keys attributes) (vals attributes)))
+ (sql/with-query-results rows [(id-query-for (db-spec-for model-name) (table-name model-name))]
+ (val (first (first rows))))))
+
(defn create
"Inserts a record populated with attributes and returns it."
[model-name attributes]

0 comments on commit 6c3c1b9

Please sign in to comment.