]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/NodeNode.hs
Merge branch 'dev' into dev-openalex
[gargantext.git] / src / Gargantext / Database / Schema / NodeNode.hs
1 {-|
2 Module : Gargantext.Database.Schema.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 Here is a longer description of this module, containing some
11 commentary with @some markup@.
12 -}
13
14 {-# LANGUAGE Arrows #-}
15 {-# LANGUAGE FunctionalDependencies #-}
16 {-# LANGUAGE QuasiQuotes #-}
17 {-# LANGUAGE TemplateHaskell #-}
18
19 module Gargantext.Database.Schema.NodeNode where
20
21 import Gargantext.Core.Types
22 import Gargantext.Database.Schema.Prelude
23 import Gargantext.Prelude
24
25
26 data NodeNodePoly node1_id node2_id score cat
27 = NodeNode { _nn_node1_id :: !node1_id
28 , _nn_node2_id :: !node2_id
29 , _nn_score :: !score
30 , _nn_category :: !cat
31 } deriving (Show)
32
33 type NodeNodeWrite = NodeNodePoly (Field SqlInt4)
34 (Field SqlInt4)
35 (Maybe (Field SqlFloat8))
36 (Maybe (Field SqlInt4))
37
38 type NodeNodeRead = NodeNodePoly (Field SqlInt4)
39 (Field SqlInt4)
40 (Field SqlFloat8)
41 (Field SqlInt4)
42
43 type NodeNode = NodeNodePoly NodeId NodeId (Maybe Double) (Maybe Int)
44
45 $(makeAdaptorAndInstance "pNodeNode" ''NodeNodePoly)
46 makeLenses ''NodeNodePoly
47
48 nodeNodeTable :: Table NodeNodeWrite NodeNodeRead
49 nodeNodeTable =
50 Table "nodes_nodes"
51 ( pNodeNode
52 NodeNode { _nn_node1_id = requiredTableField "node1_id"
53 , _nn_node2_id = requiredTableField "node2_id"
54 , _nn_score = optionalTableField "score"
55 , _nn_category = optionalTableField "category"
56 }
57 )