Skip to content

Commit

Permalink
Changed the load and save flags for sync layers to be skip-load and s…
Browse files Browse the repository at this point in the history
…kip-save instead, to make it backward compatible with clients using older versions of Remongo
  • Loading branch information
davber committed Jun 13, 2022
1 parent 258b163 commit 086dd84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject org.clojars.davber/remongo "0.2.12"
(defproject org.clojars.davber/remongo "0.2.13"
:description "ClojureScript library synchronizing Re-frame DB's and MongoDB via Realm"
:url "https://clojars.org/org.clojars.davber/remongo"
:license {:name "Unlicense"
Expand Down
13 changes: 6 additions & 7 deletions src/remongo/mongo.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@
[sync-info db-chan layer-index & {:keys [dry-run] :or {dry-run false}}]
;; We handle both nil layers and those that should not be saved naively
(let [layer (nth (:layers sync-info) layer-index)]
(if (:save layer)
(if (:skip-save layer)
db-chan
(go
(let [path (utils/stringify (:path layer))
path-key (utils/stringify (:path-key layer))
Expand Down Expand Up @@ -250,8 +251,7 @@
[(if dry-run db (dissoc-in db path))
(if dry-run db enhanced-db)])
(do (timbre/error "Trying to save with invalid sync layer:" layer)
[db enhanced-db]))))
db-chan)))
[db enhanced-db])))))))

(defn make-string
"Turn a single keyword into a string and a sequence of keywords into strings"
Expand All @@ -266,7 +266,8 @@
[sync-info db-chan layer-index]
;; We support nil layers, which are simply discarded, as are layers where :load is false
(let [layer (nth (:layers sync-info) layer-index)]
(if (:load layer)
(if (:skip-load layer)
db-chan
(go
(let [db (<! db-chan)
collection (:collection layer)
Expand Down Expand Up @@ -297,9 +298,7 @@
(update-layer-cache sync-info layer-index items)
db')
(do (timbre/error "Trying to load with invalid sync layer:" layer) db))]
db'))
;; We didn't have a proper layer, so just propagate the DB channel as is
db-chan)))
db')))))

(defn <sync-save
"Save a Reframe DB to MongoDB intelligently, returning the filtered (often empty) Reframe DB along with the enhanced DB"
Expand Down

0 comments on commit 086dd84

Please sign in to comment.