Making a complete app


#1

Originally published at: https://purelyfunctional.tv/web-dev-in-clojure/making-a-complete-app/
In this second part, we continue to build the app, rendering HTML, building customized middleware, and storing data in a database.


#2

Anyone encountered Exception in thread “main” java.lang.RuntimeException: Unable to resolve symbol: uuid-ossp in this context, compiling:(webdev/item/model.clj:5:3) ?

I have done the following:

  1. project.clj
    :dependencies […
    [org.clojure/java.jdbc “0.7.6”]
    [org.postgresql/postgresql “42.2.2”]]
    2.webdev/item/model.clj
    (ns webdev.item.model
    (:require [clojure.java.jdbc :as db]))

(defn create-table [pg-db]
(db/execute! pg-db
[“CREATE EXTENSION IF NOT EXISTS “uuid-ossp””])
(db/execute! pg-db
(println pd-db)
[“CREATE TABLE IF NOT EXISTS items
(id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name TEXT NOT NULL,
description TEXT NOT NULL,
checked BOOLEAN NOT NULL DEFAULT FALSE,
date_created TIMESTAMPTZ NOT NULL DEFAULT now())”]))
3.webdev/core.clj
(defn -main [port]
(items/create-table db))
4. Manually create uuid-ossp extensions in pgAdmin 4/webdev database
5. JDK setup: C:\Program Files\Java\jdk1.8.0_172


#3

Found the solution:

webdev/model.clj
(sql/execute! postgres
[“CREATE EXTENSION IF NOT EXISTS \“uuid-ossp\””])