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 node1_id node2_id score cat
30 = NodeNode { _nn_node1_id :: !node1_id
31 , _nn_node2_id :: !node2_id
33 , _nn_category :: !cat
36 type NodeNodeWrite = NodeNodePoly (Column (PGInt4))
38 (Maybe (Column (PGFloat8)))
39 (Maybe (Column (PGInt4)))
41 type NodeNodeRead = NodeNodePoly (Column (PGInt4))
46 type NodeNodeReadNull = NodeNodePoly (Column (Nullable PGInt4))
47 (Column (Nullable PGInt4))
48 (Column (Nullable PGFloat8))
49 (Column (Nullable PGInt4))
51 type NodeNode = NodeNodePoly NodeId NodeId (Maybe Double) (Maybe Int)
53 $(makeAdaptorAndInstance "pNodeNode" ''NodeNodePoly)
54 makeLenses ''NodeNodePoly
56 nodeNodeTable :: Table NodeNodeWrite NodeNodeRead
60 NodeNode { _nn_node1_id = required "node1_id"
61 , _nn_node2_id = required "node2_id"
62 , _nn_score = optional "score"
63 , _nn_category = optional "category"
67 instance QueryRunnerColumnDefault (Nullable PGInt4) Int where
68 queryRunnerColumnDefault = fieldQueryRunnerColumn
70 instance QueryRunnerColumnDefault (Nullable PGFloat8) Int where
71 queryRunnerColumnDefault = fieldQueryRunnerColumn
73 instance QueryRunnerColumnDefault (Nullable PGFloat8) Double where
74 queryRunnerColumnDefault = fieldQueryRunnerColumn
76 instance QueryRunnerColumnDefault PGFloat8 (Maybe Double) where
77 queryRunnerColumnDefault = fieldQueryRunnerColumn
79 instance QueryRunnerColumnDefault PGInt4 (Maybe Int) where
80 queryRunnerColumnDefault = fieldQueryRunnerColumn