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
13 {-# OPTIONS_GHC -fno-warn-orphans #-}
15 {-# LANGUAGE Arrows #-}
16 {-# LANGUAGE FunctionalDependencies #-}
17 {-# LANGUAGE QuasiQuotes #-}
18 {-# LANGUAGE TemplateHaskell #-}
21 module Gargantext.Database.Schema.NodesNgramsRepo
24 import Data.Map.Strict.Patch (PatchMap)
26 import Gargantext.Database.Schema.Prelude
27 import Gargantext.API.Ngrams.Types (NgramsStatePatch, NgramsTablePatch)
28 import Gargantext.Database.Schema.Ngrams (NgramsType)
29 import Gargantext.Database.Admin.Types.Node (NodeId)
30 import Gargantext.Prelude
33 data RepoDbPoly version patches
34 = RepoDbNgrams { _rdp_version :: !version
35 , _rdp_patches :: !patches
39 = RepoDbPoly (Column PGInt4)
42 = RepoDbPoly (Column PGInt4)
45 type RepoDbNgrams = RepoDbPoly Int NgramsStatePatch
46 $(makeAdaptorAndInstance "pRepoDbNgrams" ''RepoDbPoly)
47 makeLenses ''RepoDbPoly
49 instance DefaultFromField PGJsonb
51 (PatchMap NodeId NgramsTablePatch))
53 defaultFromField = fieldQueryRunnerColumn
55 repoTable :: Table RepoDbWrite RepoDbRead
56 repoTable = Table "nodes_ngrams_repo"
57 (pRepoDbNgrams RepoDbNgrams
58 { _rdp_version = requiredTableField "version"
59 , _rdp_patches = requiredTableField "patches"