File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed
Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -152,12 +152,12 @@ One important distinction from the Clojure atom is that inside a transaction (eg
152152; ; the fruits vector was mutated!
153153```
154154
155- If you want to prevent data from being mutated within a transaction, you must ` freeze ` it:
155+ If you want to prevent data from being mutated within a transaction, you must ` freeze! ` it:
156156
157157``` clojure
158158(swap! db (fn [moment]
159159 (let [moment (assoc moment :fruits [" apple" " pear" " grape" ])
160- moment (assoc moment :food (xdb/freeze (:fruits moment)))
160+ moment (assoc moment :food (xdb/freeze! (:fruits moment)))
161161 moment (update moment :food conj " eggs" " rice" " fish" )]
162162 moment)))
163163
Original file line number Diff line number Diff line change 231231 :else
232232 (throw (IllegalArgumentException. (str " xdb must be an instance of XITDBCursor or XITDBDatabase, got: " (type xdb))))))
233233
234- (defn freeze
234+ (defn freeze!
235235 " Prevents all data written in the current transaction from
236236 being mutated by any remaining changes. Throws if called
237237 outside of a transaction. Returns a read-only version of the
Original file line number Diff line number Diff line change 11(ns xitdb.freeze-test
2- " Tests for the `freeze` function"
2+ " Tests for the `freeze! ` function"
33 (:require
44 [clojure.test :refer :all ]
55 [xitdb.db :as xdb]
2626
2727 (swap! db (fn [moment]
2828 (let [moment (assoc moment :fruits [" apple" " pear" " grape" ])
29- moment (assoc moment :food (xdb/freeze (:fruits moment)))
29+ moment (assoc moment :food (xdb/freeze! (:fruits moment)))
3030 moment (update moment :food conj " eggs" " rice" " fish" )]
3131 moment)))
3232
5555
5656 (swap! db (fn [moment]
5757 (let [moment (assoc moment :fruits '(" apple" " pear" " grape" ))
58- moment (assoc moment :food (xdb/freeze (:fruits moment)))
58+ moment (assoc moment :food (xdb/freeze! (:fruits moment)))
5959 moment (update moment :food conj " eggs" " rice" " fish" )]
6060 moment)))
6161
8484
8585 (swap! db (fn [moment]
8686 (let [moment (assoc moment :fruits {:names [" apple" " pear" " grape" ]})
87- moment (assoc moment :food (xdb/freeze (:fruits moment)))
87+ moment (assoc moment :food (xdb/freeze! (:fruits moment)))
8888 moment (update-in moment [:food :names ] conj " eggs" " rice" " fish" )]
8989 moment)))
9090
113113
114114 (swap! db (fn [moment]
115115 (let [moment (assoc moment :fruits #{" apple" " pear" " grape" })
116- moment (assoc moment :food (xdb/freeze (:fruits moment)))
116+ moment (assoc moment :food (xdb/freeze! (:fruits moment)))
117117 moment (update moment :food conj " eggs" " rice" " fish" )]
118118 moment)))
119119
You can’t perform that action at this time.
0 commit comments