]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Query/Table/NodeNode_NodeNode.hs
[Community] Type Design (WIP)
[gargantext.git] / src / Gargantext / Database / Query / Table / NodeNode_NodeNode.hs
1 {-|
2 Module : Gargantext.Database.Query.Table.NodeNode_NodeNode
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12 {-# OPTIONS_GHC -fno-warn-orphans #-}
13
14 {-# LANGUAGE Arrows #-}
15 {-# LANGUAGE FunctionalDependencies #-}
16 {-# LANGUAGE QuasiQuotes #-}
17 {-# LANGUAGE TemplateHaskell #-}
18
19 module Gargantext.Database.Query.Table.NodeNode
20 where
21
22 import Control.Arrow (returnA)
23 import Control.Lens (view, (^.))
24 import Data.Maybe (catMaybes)
25 import Data.Text (Text, splitOn)
26 import Database.PostgreSQL.Simple.SqlQQ (sql)
27 import Database.PostgreSQL.Simple.Types (Values(..), QualifiedIdentifier(..))
28 import qualified Database.PostgreSQL.Simple as PGS (Query, Only(..))
29 import qualified Opaleye as O
30 import Opaleye
31
32 import Gargantext.Core.Types
33 import Gargantext.Database.Schema.NodeNode_NodeNode
34 import Gargantext.Database.Admin.Config (nodeTypeId)
35 import Gargantext.Database.Admin.Types.Hyperdata
36 import Gargantext.Database.Admin.Types.Node (CorpusId, DocId, pgNodeId)
37 import Gargantext.Database.Prelude
38 import Gargantext.Database.Schema.Node
39 import Gargantext.Prelude
40
41
42 queryNodeNode_NodeNodeTable :: Query NodeNode_NodeNodeRead
43 queryNodeNode_NodeNodeTable = queryTable nodeNode_NodeNodeTable
44
45 ------------------------------------------------------------------------
46 insertNodeNode_NodeNode :: [NodeNode_NodeNode] -> Cmd err Int64
47 insertNodeNode_NodeNode ns = mkCmd $ \conn -> runInsert_ conn
48 $ Insert nodeNode_NodeNodeTable ns' rCount Nothing
49 where
50 ns' :: [NodeNode_NodeNodeWrite]
51 ns' = map (\(NodeNode_NodeNode nn1 nn2 w)
52 -> NodeNode_NodeNode (pgInt4 nn1)
53 (pgInt4 nn1)
54 (pgDouble <$> x)
55 ) ns
56
57 ------------------------------------------------------------------------
58 -- | TODO delete
59 --
60
61 ------------------------------------------------------------------------