]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/NodeNode.hs
[DB/FACT] Schema NodeNgramsRepo -> Query (with warnings)
[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 {-# OPTIONS_GHC -fno-warn-orphans #-}
15
16 {-# LANGUAGE Arrows #-}
17 {-# LANGUAGE FlexibleContexts #-}
18 {-# LANGUAGE FlexibleInstances #-}
19 {-# LANGUAGE FunctionalDependencies #-}
20 {-# LANGUAGE QuasiQuotes #-}
21 {-# LANGUAGE MultiParamTypeClasses #-}
22 {-# LANGUAGE NoImplicitPrelude #-}
23 {-# LANGUAGE OverloadedStrings #-}
24 {-# LANGUAGE RankNTypes #-}
25 {-# LANGUAGE TemplateHaskell #-}
26
27 module Gargantext.Database.Schema.NodeNode where
28
29 import Data.Maybe (Maybe)
30 import Gargantext.Core.Types
31 import Gargantext.Database.Schema.Prelude
32 import Gargantext.Prelude
33
34
35 data NodeNodePoly node1_id node2_id score cat
36 = NodeNode { _nn_node1_id :: !node1_id
37 , _nn_node2_id :: !node2_id
38 , _nn_score :: !score
39 , _nn_category :: !cat
40 } deriving (Show)
41
42 type NodeNodeWrite = NodeNodePoly (Column (PGInt4))
43 (Column (PGInt4))
44 (Maybe (Column (PGFloat8)))
45 (Maybe (Column (PGInt4)))
46
47 type NodeNodeRead = NodeNodePoly (Column (PGInt4))
48 (Column (PGInt4))
49 (Column (PGFloat8))
50 (Column (PGInt4))
51
52 type NodeNodeReadNull = NodeNodePoly (Column (Nullable PGInt4))
53 (Column (Nullable PGInt4))
54 (Column (Nullable PGFloat8))
55 (Column (Nullable PGInt4))
56
57 type NodeNode = NodeNodePoly NodeId NodeId (Maybe Double) (Maybe Int)
58
59 $(makeAdaptorAndInstance "pNodeNode" ''NodeNodePoly)
60 makeLenses ''NodeNodePoly
61
62 nodeNodeTable :: Table NodeNodeWrite NodeNodeRead
63 nodeNodeTable = Table "nodes_nodes" (pNodeNode
64 NodeNode { _nn_node1_id = required "node1_id"
65 , _nn_node2_id = required "node2_id"
66 , _nn_score = optional "score"
67 , _nn_category = optional "category"
68 }
69 )
70
71
72
73 instance QueryRunnerColumnDefault (Nullable PGInt4) Int where
74 queryRunnerColumnDefault = fieldQueryRunnerColumn
75
76 instance QueryRunnerColumnDefault (Nullable PGFloat8) Int where
77 queryRunnerColumnDefault = fieldQueryRunnerColumn
78
79 instance QueryRunnerColumnDefault (Nullable PGFloat8) Double where
80 queryRunnerColumnDefault = fieldQueryRunnerColumn
81
82 instance QueryRunnerColumnDefault PGFloat8 (Maybe Double) where
83 queryRunnerColumnDefault = fieldQueryRunnerColumn
84
85 instance QueryRunnerColumnDefault PGInt4 (Maybe Int) where
86 queryRunnerColumnDefault = fieldQueryRunnerColumn
87