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 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 #-}
27 module Gargantext.Database.Schema.NodeNode where
29 import Data.Maybe (Maybe)
30 import Gargantext.Core.Types
31 import Gargantext.Database.Schema.Prelude
32 import Gargantext.Prelude
35 data NodeNodePoly node1_id node2_id score cat
36 = NodeNode { _nn_node1_id :: !node1_id
37 , _nn_node2_id :: !node2_id
39 , _nn_category :: !cat
42 type NodeNodeWrite = NodeNodePoly (Column (PGInt4))
44 (Maybe (Column (PGFloat8)))
45 (Maybe (Column (PGInt4)))
47 type NodeNodeRead = NodeNodePoly (Column (PGInt4))
52 type NodeNodeReadNull = NodeNodePoly (Column (Nullable PGInt4))
53 (Column (Nullable PGInt4))
54 (Column (Nullable PGFloat8))
55 (Column (Nullable PGInt4))
57 type NodeNode = NodeNodePoly NodeId NodeId (Maybe Double) (Maybe Int)
59 $(makeAdaptorAndInstance "pNodeNode" ''NodeNodePoly)
60 makeLenses ''NodeNodePoly
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"
73 instance QueryRunnerColumnDefault (Nullable PGInt4) Int where
74 queryRunnerColumnDefault = fieldQueryRunnerColumn
76 instance QueryRunnerColumnDefault (Nullable PGFloat8) Int where
77 queryRunnerColumnDefault = fieldQueryRunnerColumn
79 instance QueryRunnerColumnDefault (Nullable PGFloat8) Double where
80 queryRunnerColumnDefault = fieldQueryRunnerColumn
82 instance QueryRunnerColumnDefault PGFloat8 (Maybe Double) where
83 queryRunnerColumnDefault = fieldQueryRunnerColumn
85 instance QueryRunnerColumnDefault PGInt4 (Maybe Int) where
86 queryRunnerColumnDefault = fieldQueryRunnerColumn