我有上传图片的功能。有一个图片库,我需要在添加新照片时更新图库。照片上传成功,但是 UI 没有更新为新添加的照片。
我正在使用 entitydb 在本地存储列表。
我的控制器方法如下:
:post-art (pipeline! [value app-db]
(when value
(pipeline! [value app-db]
(post-art-photo app-db value)
(let [res (:createArtPicture value)]
(pp/commit! (edb/append-collection app-db :artPicture :list [(assoc res :art {:id (:artId res)})]))
(pp/commit! (assoc-in app-db [:kv :art-pictures-list] (edb/get-collection app-db :artPicture :list)))
(pp/commit! (assoc-in app-db [:kv :temp-photo] nil))
(navigate-go! {:key "art-single" :id (:artId res)}))
(rescue! [error]
nil))))
entitydb 架构是:
(def edb-schema
{:art {:id :id
:relations {:photos [:many :asset]
:authors [:many :author]
:campus [:one :campus]
:thumbnail [:one :asset]
:categories [:many :artCategory]}}
:author {:id :id
:relations {:avatar [:one :asset]
:arts [:many :art]}}
:campus {:id :id
:relations {:arts [:many :art]
:photo [:one :asset]}}
:artCategory {:id :id
:relations {:icon [:one :asset]
:arts [:many :art]}}
:artList {:id :id
:relations {:user [:one :user]
:state [:many :art]}}
:artPicture {:id :id
:relations {:user [:one :user]
:art [:one :art]}
:middleware {:set [(fn [a]
(assoc a :art {:id (:artId a)}))]}}
:comment {:id :id
:relations {:user [:one :user]
:art [:one :art]}
:middleware {:set [(fn [a]
(assoc a :art {:id (:artId a)}))]}}
:favorite {:id :id
:relations {:user [:one :user]}}
:game {:id :id
:relations {:user [:one :user]}}
:user {:id :id
:relations {:artLists [:many :artList]
:artPictures [:many :artPicture]
:comments [:many :comment]
:favorites [:many :favorite]
:games [:many :game]}}
:asset {:id :id}})
问题在于“艺术图片”。“评论”也具有相同的功能。但是,这工作正常。任何人,请帮忙?