2 Module : Gargantext.Database.Node.UpdateOpaleye
3 Description : Update Node in Database (Postgres)
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 {-# LANGUAGE QuasiQuotes #-}
15 module Gargantext.Database.Query.Table.Node.UpdateOpaleye
20 import Data.Aeson (encode, ToJSON)
21 import Gargantext.Prelude
22 import Gargantext.Database.Schema.Node
23 import Gargantext.Database.Admin.Types.Node
24 import Gargantext.Database.Prelude (Cmd, mkCmd)
25 import Gargantext.Database.Admin.Types.Node (pgNodeId)
27 updateHyperdata :: ToJSON a => NodeId -> a -> Cmd err Int64
28 updateHyperdata i h = mkCmd $ \c -> runUpdate_ c (updateHyperdataQuery i h)
30 updateHyperdataQuery :: ToJSON a => NodeId -> a -> Update Int64
31 updateHyperdataQuery i h = Update
33 , uUpdateWith = updateEasy (\ (Node _ni _nh _nt _nu _np _nn _nd _h)
34 -> Node _ni _nh _nt _nu _np _nn _nd h'
36 , uWhere = (\row -> _node_id row .== pgNodeId i )
39 where h' = (pgJSONB $ cs $ encode $ h)