Skip to content

Commit

Permalink
Create an initial version when inserting a document
Browse files Browse the repository at this point in the history
  • Loading branch information
egli committed Jun 20, 2024
1 parent 6257f34 commit 7c8a1ae
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/clj/daisyproducer2/documents/documents.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
(ns daisyproducer2.documents.documents
(:require [babashka.fs :as fs]
[conman.core :as conman]
[daisyproducer2.config :refer [env]]
[daisyproducer2.db.core :as db]
[daisyproducer2.documents.versions :as versions]
[daisyproducer2.metrics :as metrics]
[daisyproducer2.uuid :as uuid]
[iapetos.collector.fn :as prometheus]))
Expand Down Expand Up @@ -39,12 +41,14 @@
absolute-path (fs/absolutize (fs/path document-root path))]
;; make sure path exists
(fs/create-dirs (fs/parent absolute-path))
;; add an initial version
;; and store it in the db ...
(->
(db/insert-document document)
;; ... and return the new key
db/get-generated-key)))
(conman/with-transaction [db/*db*]
;; and store the document in the db ...
(let [document-id (-> (db/insert-document document)
db/get-generated-key)
document (assoc document :document-id document-id)]
;; and add an initial version
(versions/insert-initial-version document)))))

(defn update-document-meta-data
[document]
(db/update-document-meta-data document))
Expand Down

0 comments on commit 7c8a1ae

Please sign in to comment.