2 Module : Gargantext.Database.Schema.NodeNode
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 Here is a longer description of this module, containing some
11 commentary with @some markup@.
14 {-# OPTIONS_GHC -fno-warn-orphans #-}
16 {-# LANGUAGE Arrows #-}
17 {-# LANGUAGE FunctionalDependencies #-}
18 {-# LANGUAGE QuasiQuotes #-}
19 {-# LANGUAGE TemplateHaskell #-}
21 module Gargantext.Database.Schema.NodeNode where
23 import Data.Maybe (Maybe)
24 import Gargantext.Core.Types
25 import Gargantext.Database.Schema.Prelude
26 import Gargantext.Prelude
29 data NodeNodePoly n node1_id node2_id score cat
30 = NodeNode { _nn_id :: !n
31 , _nn_node1_id :: !node1_id
32 , _nn_node2_id :: !node2_id
34 , _nn_category :: !cat
37 type NodeNodeWrite = NodeNodePoly (Maybe (Column (PGInt4)))
40 (Maybe (Column (PGFloat8)))
41 (Maybe (Column (PGInt4)))
43 type NodeNodeRead = NodeNodePoly (Column (PGInt4))
49 type NodeNodeReadNull = NodeNodePoly (Column (Nullable PGInt4))
50 (Column (Nullable PGInt4))
51 (Column (Nullable PGInt4))
52 (Column (Nullable PGFloat8))
53 (Column (Nullable PGInt4))
55 type NodeNode = NodeNodePoly (Maybe Int) NodeId NodeId (Maybe Double) (Maybe Int)
57 $(makeAdaptorAndInstance "pNodeNode" ''NodeNodePoly)
58 makeLenses ''NodeNodePoly
60 nodeNodeTable :: Table NodeNodeWrite NodeNodeRead
61 nodeNodeTable = Table "nodes_nodes" (pNodeNode
62 NodeNode { _nn_id = optional "id"
63 , _nn_node1_id = required "node1_id"
64 , _nn_node2_id = required "node2_id"
65 , _nn_score = optional "score"
66 , _nn_category = optional "category"
72 instance QueryRunnerColumnDefault (Nullable PGInt4) Int where
73 queryRunnerColumnDefault = fieldQueryRunnerColumn
75 instance QueryRunnerColumnDefault (Nullable PGFloat8) Int where
76 queryRunnerColumnDefault = fieldQueryRunnerColumn
78 instance QueryRunnerColumnDefault (Nullable PGFloat8) Double where
79 queryRunnerColumnDefault = fieldQueryRunnerColumn
81 instance QueryRunnerColumnDefault PGFloat8 (Maybe Double) where
82 queryRunnerColumnDefault = fieldQueryRunnerColumn
84 instance QueryRunnerColumnDefault PGInt4 (Maybe Int) where
85 queryRunnerColumnDefault = fieldQueryRunnerColumn