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 Gargantext.Core.Types
24 import Gargantext.Database.Schema.Prelude
25 import Gargantext.Prelude
28 data NodeNodePoly node1_id node2_id score cat
29 = NodeNode { _nn_node1_id :: !node1_id
30 , _nn_node2_id :: !node2_id
32 , _nn_category :: !cat
35 type NodeNodeWrite = NodeNodePoly (Column (SqlInt4))
37 (Maybe (Column (SqlFloat8)))
38 (Maybe (Column (SqlInt4)))
40 type NodeNodeRead = NodeNodePoly (Column (SqlInt4))
45 type NodeNodeReadNull = NodeNodePoly (Column (Nullable SqlInt4))
46 (Column (Nullable SqlInt4))
47 (Column (Nullable SqlFloat8))
48 (Column (Nullable SqlInt4))
50 type NodeNode = NodeNodePoly NodeId NodeId (Maybe Double) (Maybe Int)
52 $(makeAdaptorAndInstance "pNodeNode" ''NodeNodePoly)
53 makeLenses ''NodeNodePoly
55 nodeNodeTable :: Table NodeNodeWrite NodeNodeRead
59 NodeNode { _nn_node1_id = requiredTableField "node1_id"
60 , _nn_node2_id = requiredTableField "node2_id"
61 , _nn_score = optionalTableField "score"
62 , _nn_category = optionalTableField "category"
66 instance DefaultFromField (Nullable SqlInt4) Int where
67 defaultFromField = fromPGSFromField
69 instance DefaultFromField (Nullable SqlFloat8) Int where
70 defaultFromField = fromPGSFromField
72 instance DefaultFromField (Nullable SqlFloat8) Double where
73 defaultFromField = fromPGSFromField
75 instance DefaultFromField SqlFloat8 (Maybe Double) where
76 defaultFromField = fromPGSFromField
78 instance DefaultFromField SqlInt4 (Maybe Int) where
79 defaultFromField = fromPGSFromField