Dates in and out.
This commit is contained in:
parent
0cd6da1039
commit
1e04425287
1 changed files with 18 additions and 11 deletions
|
@ -172,6 +172,9 @@
|
||||||
Long
|
Long
|
||||||
(->SQLite [x] x)
|
(->SQLite [x] x)
|
||||||
|
|
||||||
|
java.util.Date
|
||||||
|
(->SQLite [x] (.getTime x))
|
||||||
|
|
||||||
Float
|
Float
|
||||||
(->SQLite [x] x)
|
(->SQLite [x] x)
|
||||||
|
|
||||||
|
@ -188,20 +191,12 @@
|
||||||
boolean
|
boolean
|
||||||
(->SQLite [x] (if x 1 0))
|
(->SQLite [x] (if x 1 0))
|
||||||
|
|
||||||
|
js/Date
|
||||||
|
(->SQLite [x] (.getTime x))
|
||||||
|
|
||||||
number
|
number
|
||||||
(->SQLite [x] x)]))
|
(->SQLite [x] x)]))
|
||||||
|
|
||||||
(defn <-SQLite
|
|
||||||
"Transforms SQLite values to Clojure{Script}."
|
|
||||||
[valueType value]
|
|
||||||
(case valueType
|
|
||||||
:db.type/ref value
|
|
||||||
:db.type/keyword (keyword (subs value 1))
|
|
||||||
:db.type/string value
|
|
||||||
:db.type/boolean (not= value 0)
|
|
||||||
:db.type/long value
|
|
||||||
:db.type/double value))
|
|
||||||
|
|
||||||
;; Datomish rows are tagged with a numeric representation of :db/valueType:
|
;; Datomish rows are tagged with a numeric representation of :db/valueType:
|
||||||
;; The tag is used to limit queries, and therefore is placed carefully in the relevant indices to
|
;; The tag is used to limit queries, and therefore is placed carefully in the relevant indices to
|
||||||
;; allow searching numeric longs and doubles quickly. The tag is also used to convert SQLite values
|
;; allow searching numeric longs and doubles quickly. The tag is also used to convert SQLite values
|
||||||
|
@ -266,3 +261,15 @@
|
||||||
; 4 value ; JS doesn't have a Date representation.
|
; 4 value ; JS doesn't have a Date representation.
|
||||||
; 13 value ; Return the keyword string from the DB: ":foobar".
|
; 13 value ; Return the keyword string from the DB: ":foobar".
|
||||||
value))
|
value))
|
||||||
|
|
||||||
|
(defn <-SQLite
|
||||||
|
"Transforms SQLite values to Clojure{Script}."
|
||||||
|
[valueType value]
|
||||||
|
(case valueType
|
||||||
|
:db.type/ref value
|
||||||
|
:db.type/keyword (keyword (subs value 1))
|
||||||
|
:db.type/string value
|
||||||
|
:db.type/boolean (not= value 0)
|
||||||
|
:db.type/long value
|
||||||
|
:db.type/instant (<-tagged-SQLite 4 value)
|
||||||
|
:db.type/double value))
|
||||||
|
|
Loading…
Reference in a new issue