Sort posts by creation date, most recent first
This commit is contained in:
parent
973004f1dd
commit
54d35961d1
2 changed files with 26 additions and 11 deletions
|
|
@ -349,7 +349,7 @@
|
|||
refresh-id (js/Date.now)]
|
||||
(swap! state update-in [:section/posts :loading] conj refresh-id)
|
||||
(-> (js/Promise.all #js [(db/count! ::db/posts)
|
||||
(-> (db/open-cursor! ::db/posts db/all "prev")
|
||||
(-> (db/open-cursor! ::db/posts "created_at" db/all "prev")
|
||||
(db/transduce-cursor xform))])
|
||||
(.then (fn [[total displayed-posts]]
|
||||
(swap! state update :section/posts #(-> (assoc % :total total)
|
||||
|
|
@ -407,12 +407,15 @@
|
|||
|
||||
;; database
|
||||
|
||||
(def db-version 1)
|
||||
(def db-version 2)
|
||||
|
||||
(def migrations
|
||||
{1 (fn migration-0001 [db]
|
||||
{1 (fn migration-0001 [db _]
|
||||
(db/create-object-store! db ::db/application {:keyPath "id"})
|
||||
(db/create-object-store! db ::db/posts {:keyPath "id"}))})
|
||||
(db/create-object-store! db ::db/posts {:keyPath "id"}))
|
||||
2 (fn migration-0002 [_ txn]
|
||||
(-> (db/open-store txn ::db/posts "readwrite")
|
||||
(db/create-index! "created_at" "created_at" {:unique false})))})
|
||||
|
||||
;; go go go
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue