start work on database support

This commit is contained in:
John Bintz 2016-01-14 07:07:50 -05:00
parent 74ab417191
commit cc8000a48b
3 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,39 @@
(ns picture-processor.db)
(def sqlite3 (js/require "sqlite3"))
(def database (aget sqlite3 "Database"))
(def -db (atom nil))
(defn connection
"Get the current database connection"
[]
@-db)
(defn open
"Open the database connection"
[]
(reset! -db (database. "db/dev.db")))
(defn close
"Close the database connection"
[]
(.close @-db)
(reset! -db nil))
(defn in-series
"Run SQL commands in series"
[code]
(.serialize @-db (code @-db)))
(defn run
"Run SQL command"
[cmd & args]
(let [statement (.prepare @-db cmd)]
(apply (.run statement & )
)
)
(in-series (fn [db]
(.log js/console (.run db))
))

View File

@ -0,0 +1,6 @@
(ns picture-processor.images.data)
(defn create
[data]
"Store an image's info in the database"
)

View File

@ -1,4 +1,4 @@
(ns picture-processor.images)
(ns picture-processor.images.process)
(def fs (js/require "fs"))
(def imagemagick (js/require "imagemagick-native"))