Browse Source

fix: db kv id always resolves to -1

Tienson Qin 1 year ago
parent
commit
41bd5ac74d
2 changed files with 3 additions and 3 deletions
  1. 2 2
      src/main/frontend/db/conn.cljs
  2. 1 1
      src/main/frontend/handler/repo.cljs

+ 2 - 2
src/main/frontend/db/conn.cljs

@@ -83,8 +83,8 @@
   (swap! conns dissoc (datascript-db repo)))
 
 (defn kv
-  [key value]
-  {:db/id -1
+  [key value & {:keys [id]}]
+  {:db/id (or id -1)
    :db/ident key
    key value})
 

+ 1 - 1
src/main/frontend/handler/repo.cljs

@@ -536,7 +536,7 @@
           _ (state/add-repo! {:url full-graph-name})
           _ (route-handler/redirect-to-home!)
           _ (db/transact! full-graph-name [(react/kv :db/type "db")
-                                           (react/kv :schema/version db-schema/version)])
+                                           (react/kv :schema/version db-schema/version {:id -2})])
           initial-data (sqlite-create-graph/build-db-initial-data config/config-default-content)
           _ (db/transact! full-graph-name initial-data)
           _ (repo-config-handler/set-repo-config-state! full-graph-name config/config-default-content)