Merge remote-tracking branch 'origin/flexible-job-queue' into dev
[gargantext.git] / src / Gargantext / Database / Schema / Node.hs
index 876fc52047da8649acd1d58b7546c6947a901ed6..cb6d4b5fd4d65c98358528feb830da0987f2119c 100644 (file)
@@ -28,8 +28,8 @@ import Prelude hiding (null, id, map, sum)
 data NodePoly id
               hash_id
               typename
-              userId
-              parentId
+              user_id
+              parent_id
               name
               date
               hyperdata  =
@@ -37,8 +37,8 @@ data NodePoly id
           , _node_hash_id   :: !hash_id
           , _node_typename  :: !typename
 
-          , _node_userId    :: !userId
-          , _node_parentId  :: !parentId
+          , _node_user_id    :: !user_id
+          , _node_parent_id  :: !parent_id
 
           , _node_name      :: !name
           , _node_date      :: !date
@@ -55,105 +55,105 @@ $(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"
+nodeTable = Table "nodes" (pNode Node { _node_id         = optionalTableField "id"
+                                      , _node_hash_id    = optionalTableField "hash_id"
+                                      , _node_typename   = requiredTableField "typename"
+                                      , _node_user_id    = requiredTableField "user_id"
 
-                                      , _node_parentId   = optional "parent_id"
-                                      , _node_name       = required "name"
-                                      , _node_date       = optional "date"
+                                      , _node_parent_id  = optionalTableField "parent_id"
+                                      , _node_name       = requiredTableField "name"
+                                      , _node_date       = optionalTableField "date"
 
-                                      , _node_hyperdata  = required "hyperdata"
+                                      , _node_hyperdata  = requiredTableField "hyperdata"
                                       -- ignoring ts_vector field here
                                       }
                             )
 
 queryNodeTable :: Query NodeRead
-queryNodeTable = queryTable nodeTable
+queryNodeTable = selectTable nodeTable
 ------------------------------------------------------------------------
-type NodeWrite = NodePoly (Maybe (Column PGInt4)      )
-                          (Maybe (Column PGText)      )
-                                 (Column PGInt4)
-                                 (Column PGInt4)
-                          (Maybe (Column PGInt4)      )
-                                 (Column PGText)
-                          (Maybe (Column PGTimestamptz))
-                                 (Column PGJsonb)
-
-type NodeRead = NodePoly (Column PGInt4        )
-                         (Column PGText        )
-                         (Column PGInt4        )
-                         (Column PGInt4        )
-                         (Column PGInt4        )
-                         (Column PGText        )
-                         (Column PGTimestamptz )
-                         (Column PGJsonb       )
-
-type NodeReadNull = NodePoly (Column (Nullable PGInt4))
-                             (Column (Nullable PGText))
-                             (Column (Nullable PGInt4))
-                             (Column (Nullable PGInt4))
-                             (Column (Nullable PGInt4))
-                             (Column (Nullable PGText))
-                             (Column (Nullable PGTimestamptz))
-                             (Column (Nullable PGJsonb))
+type NodeWrite = NodePoly (Maybe (Column SqlInt4)      )
+                          (Maybe (Column SqlText)      )
+                                 (Column SqlInt4)
+                                 (Column SqlInt4)
+                          (Maybe (Column SqlInt4)      )
+                                 (Column SqlText)
+                          (Maybe (Column SqlTimestamptz))
+                                 (Column SqlJsonb)
+
+type NodeRead = NodePoly (Column SqlInt4        )
+                         (Column SqlText        )
+                         (Column SqlInt4        )
+                         (Column SqlInt4        )
+                         (Column SqlInt4        )
+                         (Column SqlText        )
+                         (Column SqlTimestamptz )
+                         (Column SqlJsonb       )
+
+type NodeReadNull = NodePoly (Column (Nullable SqlInt4))
+                             (Column (Nullable SqlText))
+                             (Column (Nullable SqlInt4))
+                             (Column (Nullable SqlInt4))
+                             (Column (Nullable SqlInt4))
+                             (Column (Nullable SqlText))
+                             (Column (Nullable SqlTimestamptz))
+                             (Column (Nullable SqlJsonb))
 ------------------------------------------------------------------------
 -- | Node(Read|Write)Search is slower than Node(Write|Read) use it
 -- for full text search only
 
 type NodeSearchWrite =
   NodePolySearch
-    (Maybe  (Column  PGInt4)      )
-    (Column  PGInt4               )
-    (Column  PGInt4               )
-    (Column (Nullable PGInt4)     )
-    (Column PGText                )
-    (Maybe  (Column PGTimestamptz))
-    (Column  PGJsonb              )
-    (Maybe  (Column PGTSVector)   )
+    (Maybe  (Column  SqlInt4)      )
+    (Column  SqlInt4               )
+    (Column  SqlInt4               )
+    (Column (Nullable SqlInt4)     )
+    (Column SqlText                )
+    (Maybe  (Column SqlTimestamptz))
+    (Column  SqlJsonb              )
+    (Maybe  (Column SqlTSVector)   )
 
 type NodeSearchRead =
   NodePolySearch
-    (Column  PGInt4           )
-    (Column  PGInt4           )
-    (Column  PGInt4           )
-    (Column (Nullable PGInt4 ))
-    (Column  PGText           )
-    (Column  PGTimestamptz    )
-    (Column  PGJsonb          )
-    (Column  PGTSVector       )
+    (Column  SqlInt4           )
+    (Column  SqlInt4           )
+    (Column  SqlInt4           )
+    (Column (Nullable SqlInt4 ))
+    (Column  SqlText           )
+    (Column  SqlTimestamptz    )
+    (Column  SqlJsonb          )
+    (Column  SqlTSVector       )
 
 type NodeSearchReadNull =
   NodePolySearch
-    (Column (Nullable PGInt4)       )
-    (Column (Nullable PGInt4)       )
-    (Column (Nullable PGInt4)       )
-    (Column (Nullable PGInt4)       )
-    (Column (Nullable PGText)       )
-    (Column (Nullable PGTimestamptz))
-    (Column (Nullable PGJsonb)      )
-    (Column (Nullable PGTSVector)   )
+    (Column (Nullable SqlInt4)       )
+    (Column (Nullable SqlInt4)       )
+    (Column (Nullable SqlInt4)       )
+    (Column (Nullable SqlInt4)       )
+    (Column (Nullable SqlText)       )
+    (Column (Nullable SqlTimestamptz))
+    (Column (Nullable SqlJsonb)      )
+    (Column (Nullable SqlTSVector)   )
 
 
 data NodePolySearch id
                     typename
-                    userId
-                    parentId
+                    user_id
+                    parent_id
                     name
                     date
                     hyperdata
                     search =
-     NodeSearch { _ns_id        :: id
-                , _ns_typename  :: typename
-                , _ns_userId    :: userId
-                                          --   , nodeUniqId    :: shaId
-                , _ns_parentId  :: parentId
-                , _ns_name      :: name
-                , _ns_date      :: date
-
-                , _ns_hyperdata :: hyperdata
-                , _ns_search    :: search
+     NodeSearch { _ns_id           :: id
+                , _ns_typename     :: typename
+                , _ns_user_id      :: user_id
+           --   , nodeUniqId       :: shaId
+                , _ns_parent_id    :: parent_id
+                , _ns_name         :: name
+                , _ns_date         :: date
+
+                , _ns_hyperdata    :: hyperdata
+                , _ns_search       :: search
                 } deriving (Show, Generic)
 
 $(makeAdaptorAndInstance "pNodeSearch" ''NodePolySearch)
@@ -163,16 +163,16 @@ $(makeLenses ''NodePolySearch)
 
 nodeTableSearch :: Table NodeSearchWrite NodeSearchRead
 nodeTableSearch = Table "nodes" ( pNodeSearch
-                                   NodeSearch { _ns_id         = optional "id"
-                                              , _ns_typename   = required "typename"
-                                              , _ns_userId     = required "user_id"
+                                   NodeSearch { _ns_id           = optionalTableField "id"
+                                              , _ns_typename     = requiredTableField "typename"
+                                              , _ns_user_id      = requiredTableField "user_id"
 
-                                              , _ns_parentId   = required "parent_id"
-                                              , _ns_name       = required "name"
-                                              , _ns_date       = optional "date"
+                                              , _ns_parent_id    = requiredTableField "parent_id"
+                                              , _ns_name         = requiredTableField "name"
+                                              , _ns_date         = optionalTableField "date"
 
-                                              , _ns_hyperdata  = required "hyperdata"
-                                              , _ns_search     = optional "search"
+                                              , _ns_hyperdata    = requiredTableField "hyperdata"
+                                              , _ns_search       = optionalTableField "search"
                                               }
                                 )
 ------------------------------------------------------------------------