[tree] refactor "root" variable name
[gargantext.git] / src / Gargantext / Database / Schema / Node.hs
index 69a41d34155cd4c204b7a91013e136619f0c8759..876fc52047da8649acd1d58b7546c6947a901ed6 100644 (file)
@@ -8,34 +8,25 @@ Stability   : experimental
 Portability : POSIX
 -}
 
-{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
+
 {-# OPTIONS_GHC -fno-warn-orphans        #-}
 
 {-# LANGUAGE Arrows                 #-}
-{-# LANGUAGE DeriveGeneric          #-}
 {-# LANGUAGE ConstraintKinds        #-}
-{-# LANGUAGE FlexibleContexts       #-}
-{-# LANGUAGE FlexibleInstances      #-}
 {-# LANGUAGE FunctionalDependencies #-}
-{-# LANGUAGE OverloadedStrings      #-}
-{-# LANGUAGE MultiParamTypeClasses  #-}
-{-# LANGUAGE NoImplicitPrelude      #-}
-{-# LANGUAGE RankNTypes             #-}
 {-# LANGUAGE TemplateHaskell        #-}
 {-# LANGUAGE TypeFamilies           #-}
 
 module Gargantext.Database.Schema.Node where
 
 import Control.Lens hiding (elements, (&))
-import Data.Text (Text)
-import Gargantext.Database.Admin.Utils
 import Gargantext.Database.Schema.Prelude
 import Prelude hiding (null, id, map, sum)
 
 ------------------------------------------------------------------------
 -- Main polymorphic Node definition
-
 data NodePoly id
+              hash_id
               typename
               userId
               parentId
@@ -43,6 +34,7 @@ data NodePoly id
               date
               hyperdata  =
      Node { _node_id        :: !id
+          , _node_hash_id   :: !hash_id
           , _node_typename  :: !typename
 
           , _node_userId    :: !userId
@@ -62,9 +54,9 @@ $(makeLenses ''NodePoly)
 $(makeAdaptorAndInstance "pNode"   ''NodePoly)
 $(makeLensesWith abbreviatedFields ''NodePoly)
 
-------------------------------------------------------------------------
 nodeTable :: Table NodeWrite NodeRead
 nodeTable = Table "nodes" (pNode Node { _node_id         = optional "id"
+                                      , _node_hash_id    = optional "hash_id"
                                       , _node_typename   = required "typename"
                                       , _node_userId     = required "user_id"
 
@@ -81,6 +73,7 @@ queryNodeTable :: Query NodeRead
 queryNodeTable = queryTable nodeTable
 ------------------------------------------------------------------------
 type NodeWrite = NodePoly (Maybe (Column PGInt4)      )
+                          (Maybe (Column PGText)      )
                                  (Column PGInt4)
                                  (Column PGInt4)
                           (Maybe (Column PGInt4)      )
@@ -89,6 +82,7 @@ type NodeWrite = NodePoly (Maybe (Column PGInt4)      )
                                  (Column PGJsonb)
 
 type NodeRead = NodePoly (Column PGInt4        )
+                         (Column PGText        )
                          (Column PGInt4        )
                          (Column PGInt4        )
                          (Column PGInt4        )
@@ -97,6 +91,7 @@ type NodeRead = NodePoly (Column PGInt4        )
                          (Column PGJsonb       )
 
 type NodeReadNull = NodePoly (Column (Nullable PGInt4))
+                             (Column (Nullable PGText))
                              (Column (Nullable PGInt4))
                              (Column (Nullable PGInt4))
                              (Column (Nullable PGInt4))
@@ -167,16 +162,17 @@ $(deriveJSON (unPrefix "_ns_")     ''NodePolySearch)
 $(makeLenses ''NodePolySearch)
 
 nodeTableSearch :: Table NodeSearchWrite NodeSearchRead
-nodeTableSearch = Table "nodes" (pNodeSearch NodeSearch { _ns_id         = optional "id"
-                                      , _ns_typename   = required "typename"
-                                      , _ns_userId     = required "user_id"
-
-                                      , _ns_parentId   = required "parent_id"
-                                      , _ns_name       = required "name"
-                                      , _ns_date       = optional "date"
-
-                                      , _ns_hyperdata  = required "hyperdata"
-                                      , _ns_search     = optional "search"
-                                      }
-                            )
+nodeTableSearch = Table "nodes" ( pNodeSearch
+                                   NodeSearch { _ns_id         = optional "id"
+                                              , _ns_typename   = required "typename"
+                                              , _ns_userId     = required "user_id"
+
+                                              , _ns_parentId   = required "parent_id"
+                                              , _ns_name       = required "name"
+                                              , _ns_date       = optional "date"
+
+                                              , _ns_hyperdata  = required "hyperdata"
+                                              , _ns_search     = optional "search"
+                                              }
+                                )
 ------------------------------------------------------------------------