]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/NodesNgramsRepo.hs
[FEAT|COLLAB] delete team node enabled preserving rights
[gargantext.git] / src / Gargantext / Database / Schema / NodesNgramsRepo.hs
1 {-|
2 Module : Gargantext.Database.Schema.NodesNgramsRepo
3 Description : NodeNgram for Ngram indexation or Lists
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10
11 -}
12
13 {-# OPTIONS_GHC -fno-warn-orphans #-}
14
15 {-# LANGUAGE Arrows #-}
16 {-# LANGUAGE FunctionalDependencies #-}
17 {-# LANGUAGE QuasiQuotes #-}
18 {-# LANGUAGE TemplateHaskell #-}
19
20
21 module Gargantext.Database.Schema.NodesNgramsRepo
22 where
23
24 import Data.Map.Strict.Patch (PatchMap)
25 import Gargantext.Database.Schema.Prelude
26 import Gargantext.API.Ngrams (NgramsStatePatch, NgramsTablePatch)
27 import Gargantext.Database.Schema.Ngrams (NgramsType)
28 import Gargantext.Database.Admin.Types.Node (NodeId)
29 import Gargantext.Prelude
30
31
32 data RepoDbPoly version patches
33 = RepoDbNgrams { _rdp_version :: !version
34 , _rdp_patches :: !patches
35 } deriving (Show)
36
37 type RepoDbWrite
38 = RepoDbPoly (Column PGInt4)
39 (Column PGJsonb)
40 type RepoDbRead
41 = RepoDbPoly (Column PGInt4)
42 (Column PGJsonb)
43
44 type RepoDbNgrams = RepoDbPoly Int NgramsStatePatch
45 $(makeAdaptorAndInstance "pRepoDbNgrams" ''RepoDbPoly)
46 makeLenses ''RepoDbPoly
47
48 instance QueryRunnerColumnDefault PGJsonb
49 (PatchMap NgramsType
50 (PatchMap NodeId NgramsTablePatch))
51 where
52 queryRunnerColumnDefault = fieldQueryRunnerColumn
53
54 repoTable :: Table RepoDbWrite RepoDbRead
55 repoTable = Table "nodes_ngrams_repo"
56 (pRepoDbNgrams RepoDbNgrams
57 { _rdp_version = required "version"
58 , _rdp_patches = required "patches"
59 }
60 )
61