1 {-# LANGUAGE TemplateHaskell #-}
2 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE FunctionalDependencies #-}
5 {-# LANGUAGE Arrows #-}
6 {-# OPTIONS_GHC -fno-warn-orphans #-}
9 module Gargantext.Database.NodeNgram where
12 import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
13 import Control.Lens.TH (makeLensesWith, abbreviatedFields)
17 data NodeNgramPoly id node_id ngram_id weight
18 = NodeNgram { nodeNgram_NodeNgramId :: id
19 , nodeNgram_NodeNgramNodeId :: node_id
20 , nodeNgram_NodeNgramNgramId :: ngram_id
21 , nodeNgram_NodeNgramWeight :: weight
24 type NodeNgramWrite = NodeNgramPoly (Column PGInt4 )
29 type NodeNgramRead = NodeNgramPoly (Column PGInt4 )
34 type NodeNgram = NodeNgramPoly Int Int Int Double
36 $(makeAdaptorAndInstance "pNodeNgram" ''NodeNgramPoly)
37 $(makeLensesWith abbreviatedFields ''NodeNgramPoly)
40 nodeNgramTable :: Table NodeNgramWrite NodeNgramRead
41 nodeNgramTable = Table "nodes_ngrams" ( pNodeNgram NodeNgram
42 { nodeNgram_NodeNgramId = required "id"
43 , nodeNgram_NodeNgramNodeId = required "node_id"
44 , nodeNgram_NodeNgramNgramId = required "ngram_id"
45 , nodeNgram_NodeNgramWeight = required "weight"
49 queryNodeNgramTable :: Query NodeNgramRead
50 queryNodeNgramTable = queryTable nodeNgramTable