2 Module : Gargantext.Database.Node.Select
3 Description : Main requests of Node to the database
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 {-# LANGUAGE Arrows #-}
14 module Gargantext.Database.Query.Table.Node.Select
17 import Control.Arrow (returnA)
21 import Gargantext.Core
22 import Gargantext.Core.Types
23 import Gargantext.Core.Types.Individu (Username)
24 import Gargantext.Database.Prelude
25 import Gargantext.Database.Schema.Node
26 import Gargantext.Database.Schema.User
27 import Gargantext.Database.Query.Table.User
29 selectNodesWithUsername :: NodeType -> Username -> Cmd err [NodeId]
30 selectNodesWithUsername nt u = runOpaQuery (q u)
33 (n,usrs) <- join' -< ()
34 restrict -< user_username usrs .== (toNullable $ sqlStrictText u')
35 restrict -< _node_typename n .== (sqlInt4 $ toDBid nt)
38 join' :: Select (NodeRead, UserReadNull)
39 join' = leftJoin queryNodeTable queryUserTable on1
41 on1 (n,us) = _node_user_id n .== user_id us