|
15 | 15 | ;; SUMMING UP |
16 | 16 |
|
17 | 17 | (defn ^:declared q [q & inputs]) |
18 | | -(def ^:export q dq/q) |
| 18 | +(def q dq/q) |
19 | 19 |
|
20 | 20 | (defn ^:declared entity [db eid]) |
21 | | -(def ^:export entity de/entity) |
| 21 | +(def entity de/entity) |
22 | 22 |
|
23 | | -(defn ^:export entity-db [^Entity entity] |
| 23 | +(defn entity-db [^Entity entity] |
24 | 24 | {:pre [(de/entity? entity)]} |
25 | 25 | (.-db entity)) |
26 | 26 |
|
27 | 27 | (defn ^:declared datom ([e a v]) ([e a v tx]) ([e a v tx added])) |
28 | | -(def ^:export datom db/datom) |
| 28 | +(def datom db/datom) |
29 | 29 |
|
30 | 30 | (defn ^:declared pull [db selector eid]) |
31 | | -(def ^:export pull dp/pull) |
| 31 | +(def pull dp/pull) |
32 | 32 |
|
33 | 33 | (defn ^:declared pull-many [db selector eids]) |
34 | | -(def ^:export pull-many dp/pull-many) |
| 34 | +(def pull-many dp/pull-many) |
35 | 35 |
|
36 | 36 | (defn ^:declared touch [e]) |
37 | | -(def ^:export touch de/touch) |
| 37 | +(def touch de/touch) |
38 | 38 |
|
39 | 39 | (defn ^:declared empty-db ([]) ([schema])) |
40 | | -(def ^:export empty-db db/empty-db) |
| 40 | +(def empty-db db/empty-db) |
41 | 41 |
|
42 | 42 | (defn ^:declared init-db ([datoms]) ([datoms schema])) |
43 | | -(def ^:export init-db db/init-db) |
| 43 | +(def init-db db/init-db) |
44 | 44 |
|
45 | 45 | (defn ^:declared datom? [x]) |
46 | | -(def ^:export datom? db/datom?) |
| 46 | +(def datom? db/datom?) |
47 | 47 |
|
48 | 48 | (defn ^:declared db? [x]) |
49 | | -(def ^:export db? db/db?) |
| 49 | +(def db? db/db?) |
50 | 50 |
|
51 | | -(def ^:export ^:const tx0 db/tx0) |
| 51 | +(def ^:const tx0 db/tx0) |
52 | 52 |
|
53 | | -(defn ^:export is-filtered [x] |
| 53 | +(defn is-filtered [x] |
54 | 54 | (instance? FilteredDB x)) |
55 | 55 |
|
56 | | -(defn ^:export filter [db pred] |
| 56 | +(defn filter [db pred] |
57 | 57 | {:pre [(db/db? db)]} |
58 | 58 | (if (is-filtered db) |
59 | 59 | (let [^FilteredDB fdb db |
|
62 | 62 | (FilteredDB. orig-db #(and (orig-pred %) (pred orig-db %)) (atom 0))) |
63 | 63 | (FilteredDB. db #(pred db %) (atom 0)))) |
64 | 64 |
|
65 | | -(defn ^:export with |
| 65 | +(defn with |
66 | 66 | ([db tx-data] (with db tx-data nil)) |
67 | 67 | ([db tx-data tx-meta] |
68 | 68 | {:pre [(db/db? db)]} |
|
75 | 75 | :tempids {} |
76 | 76 | :tx-meta tx-meta}) tx-data)))) |
77 | 77 |
|
78 | | -(defn ^:export db-with [db tx-data] |
| 78 | +(defn db-with [db tx-data] |
79 | 79 | {:pre [(db/db? db)]} |
80 | 80 | (:db-after (with db tx-data))) |
81 | 81 |
|
82 | | -(defn ^:export datoms |
| 82 | +(defn datoms |
83 | 83 | ([db index] {:pre [(db/db? db)]} (db/-datoms db index [])) |
84 | 84 | ([db index c1] {:pre [(db/db? db)]} (db/-datoms db index [c1])) |
85 | 85 | ([db index c1 c2] {:pre [(db/db? db)]} (db/-datoms db index [c1 c2])) |
86 | 86 | ([db index c1 c2 c3] {:pre [(db/db? db)]} (db/-datoms db index [c1 c2 c3])) |
87 | 87 | ([db index c1 c2 c3 c4] {:pre [(db/db? db)]} (db/-datoms db index [c1 c2 c3 c4]))) |
88 | 88 |
|
89 | | -(defn ^:export seek-datoms |
| 89 | +(defn seek-datoms |
90 | 90 | ([db index] {:pre [(db/db? db)]} (db/-seek-datoms db index [])) |
91 | 91 | ([db index c1] {:pre [(db/db? db)]} (db/-seek-datoms db index [c1])) |
92 | 92 | ([db index c1 c2] {:pre [(db/db? db)]} (db/-seek-datoms db index [c1 c2])) |
93 | 93 | ([db index c1 c2 c3] {:pre [(db/db? db)]} (db/-seek-datoms db index [c1 c2 c3])) |
94 | 94 | ([db index c1 c2 c3 c4] {:pre [(db/db? db)]} (db/-seek-datoms db index [c1 c2 c3 c4]))) |
95 | 95 |
|
96 | | -(defn ^:export index-range [db attr start end] |
| 96 | +(defn index-range [db attr start end] |
97 | 97 | {:pre [(db/db? db)]} |
98 | 98 | (db/-index-range db attr start end)) |
99 | 99 |
|
100 | 100 | (defn ^:declared entid [db eid]) |
101 | | -(def ^:export entid db/entid) |
| 101 | +(def entid db/entid) |
102 | 102 |
|
103 | 103 | ;; Conn |
104 | 104 |
|
105 | | -(defn ^:export conn? [conn] |
| 105 | +(defn conn? [conn] |
106 | 106 | (and #?(:clj (instance? clojure.lang.IDeref conn) |
107 | 107 | :cljs (satisfies? cljs.core/IDeref conn)) |
108 | 108 | (db/db? @conn))) |
109 | 109 |
|
110 | | -(defn ^:export conn-from-db [db] |
| 110 | +(defn conn-from-db [db] |
111 | 111 | (atom db :meta { :listeners (atom {}) })) |
112 | 112 |
|
113 | | -(defn ^:export conn-from-datoms |
| 113 | +(defn conn-from-datoms |
114 | 114 | ([datoms] (conn-from-db (init-db datoms))) |
115 | 115 | ([datoms schema] (conn-from-db (init-db datoms schema)))) |
116 | 116 |
|
117 | | -(defn ^:export create-conn |
| 117 | +(defn create-conn |
118 | 118 | ([] (conn-from-db (empty-db))) |
119 | 119 | ([schema] (conn-from-db (empty-db schema)))) |
120 | 120 |
|
|
127 | 127 | (:db-after r)))) |
128 | 128 | @report)) |
129 | 129 |
|
130 | | -(defn ^:export transact! |
| 130 | +(defn transact! |
131 | 131 | ([conn tx-data] (transact! conn tx-data nil)) |
132 | 132 | ([conn tx-data tx-meta] |
133 | 133 | {:pre [(conn? conn)]} |
|
136 | 136 | (callback report)) |
137 | 137 | report))) |
138 | 138 |
|
139 | | -(defn ^:export reset-conn! |
| 139 | +(defn reset-conn! |
140 | 140 | ([conn db] (reset-conn! conn db nil)) |
141 | 141 | ([conn db tx-meta] |
142 | 142 | (let [report (db/map->TxReport |
|
151 | 151 | (callback report)) |
152 | 152 | db))) |
153 | 153 |
|
154 | | -(defn ^:export listen! |
| 154 | +(defn listen! |
155 | 155 | ([conn callback] (listen! conn (rand) callback)) |
156 | 156 | ([conn key callback] |
157 | 157 | {:pre [(conn? conn)]} |
158 | 158 | (swap! (:listeners (meta conn)) assoc key callback) |
159 | 159 | key)) |
160 | 160 |
|
161 | | -(defn ^:export unlisten! [conn key] |
| 161 | +(defn unlisten! [conn key] |
162 | 162 | {:pre [(conn? conn)]} |
163 | 163 | (swap! (:listeners (meta conn)) dissoc key)) |
164 | 164 |
|
|
182 | 182 |
|
183 | 183 | (def ^:private last-tempid (atom -1000000)) |
184 | 184 |
|
185 | | -(defn ^:export tempid |
| 185 | +(defn tempid |
186 | 186 | ([part] |
187 | 187 | (if (= part :db.part/tx) |
188 | 188 | :db/current-tx |
|
192 | 192 | :db/current-tx |
193 | 193 | x))) |
194 | 194 |
|
195 | | -(defn ^:export resolve-tempid [_db tempids tempid] |
| 195 | +(defn resolve-tempid [_db tempids tempid] |
196 | 196 | (get tempids tempid)) |
197 | 197 |
|
198 | | -(defn ^:export db [conn] |
| 198 | +(defn db [conn] |
199 | 199 | {:pre [(conn? conn)]} |
200 | 200 | @conn) |
201 | 201 |
|
202 | | -(defn ^:export transact |
| 202 | +(defn transact |
203 | 203 | ([conn tx-data] (transact conn tx-data nil)) |
204 | 204 | ([conn tx-data tx-meta] |
205 | 205 | {:pre [(conn? conn)]} |
|
235 | 235 | IPending |
236 | 236 | (-realized? [_] @realized))))) |
237 | 237 |
|
238 | | -(defn ^:export transact-async |
| 238 | +(defn transact-async |
239 | 239 | ([conn tx-data] (transact-async conn tx-data nil)) |
240 | 240 | ([conn tx-data tx-meta] |
241 | 241 | {:pre [(conn? conn)]} |
|
253 | 253 | (< c l) (str (apply str (repeat (- l c) "0")) s) |
254 | 254 | :else s)))) |
255 | 255 |
|
256 | | -(defn ^:export squuid |
| 256 | +(defn squuid |
257 | 257 | ([] |
258 | 258 | (squuid #?(:clj (System/currentTimeMillis) |
259 | 259 | :cljs (.getTime (js/Date.))))) |
|
278 | 278 | (-> (rand-bits 16) (to-hex-string 4)) |
279 | 279 | (-> (rand-bits 16) (to-hex-string 4))))))) |
280 | 280 |
|
281 | | -(defn ^:export squuid-time-millis [uuid] |
| 281 | +(defn squuid-time-millis [uuid] |
282 | 282 | #?(:clj (-> (.getMostSignificantBits ^UUID uuid) |
283 | 283 | (bit-shift-right 32) |
284 | 284 | (* 1000)) |
|
0 commit comments