   (:require [clojure.java.jdbc :as sql]))
 
 (def db {:classname "org.postgresql.Driver"
-		 :subprotocol "postgresql"
-		 :subname "//localhost:5432/cwl"
-		 :user "cwl"
-		 :password "wish"})
+         :subprotocol "postgresql"
+         :subname "//localhost:5432/cwl"
+         :user "cwl"
+         :password "wish"})
 ;wishlist
 ;[:id :serial "PRIMARY KEY"]
 ;[:title :varchar "NOT NULL"]
-;[:code :varchar :unique "NOT NULL"]
+;[:code :varchar :unique]
 ;[:created_at :timestamp "NOT NULL" "DEFAULT CURRENT_TIMESTAMP"])))
 
 ;wish

;[:wishlist :int]
;["constraint fk_wish_wishlist foreign key(wishlist) references Wishlist(id) on delete cascade"])))

(defn get-wishlist [{:keys [code]}] ; code is unique not null
  (sql/with-connection db
	(sql/with-query-results results
      ["select * from wishlist where code=?" code]
      (first (into [] results)))))

(defn insert-wishlist [wishlist]
  (sql/with-connection db
	(sql/insert-records :wishlist wishlist)))

(defn delete-wishlist [{:keys [code]}] ; code is unique not null
  (sql/with-connection db

(defn update-wishlist [wish]
  (let [{:keys [id]} wish]
    (sql/with-connection db
      (sql/update-values :wish ["id=?" id] wish))))
