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
date
hyperdata =
Node { _node_id :: !id
+ , _node_hash_id :: !hash_id
, _node_typename :: !typename
, _node_userId :: !userId
$(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"
queryNodeTable = queryTable nodeTable
------------------------------------------------------------------------
type NodeWrite = NodePoly (Maybe (Column PGInt4) )
+ (Maybe (Column PGText) )
(Column PGInt4)
(Column PGInt4)
(Maybe (Column PGInt4) )
(Column PGJsonb)
type NodeRead = NodePoly (Column PGInt4 )
+ (Column PGText )
(Column PGInt4 )
(Column PGInt4 )
(Column PGInt4 )
(Column PGJsonb )
type NodeReadNull = NodePoly (Column (Nullable PGInt4))
+ (Column (Nullable PGText))
(Column (Nullable PGInt4))
(Column (Nullable PGInt4))
(Column (Nullable PGInt4))
$(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"
+ }
+ )
------------------------------------------------------------------------