Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
145
Issues
145
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
ab5be1ab
Commit
ab5be1ab
authored
Oct 13, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FILE] missing in git.
parent
c9d2df42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
Update.hs
src/Gargantext/Database/Node/Update.hs
+52
-0
No files found.
src/Gargantext/Database/Node/Update.hs
0 → 100644
View file @
ab5be1ab
{-|
Module : Gargantext.Database.Node.Update
Description : Update Node in Database (Postgres)
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE QuasiQuotes #-}
module
Gargantext.Database.Node.Update
(
Update
(
..
),
update
)
where
import
Control.Lens
(
Prism
'
,
(
#
),
(
^..
),
at
,
each
,
_Just
,
to
)
import
Control.Monad.Error.Class
(
MonadError
(
throwError
))
import
Control.Monad.IO.Class
(
MonadIO
(
liftIO
))
import
Data.Map
(
Map
,
fromListWith
,
lookup
)
import
Data.Text
(
Text
)
import
qualified
Data.Text
as
DT
import
Database.PostgreSQL.Simple
import
Database.PostgreSQL.Simple.SqlQQ
import
Gargantext.Prelude
import
Gargantext.Database.Node
(
Cmd
(
..
))
import
Gargantext.Core.Types.Main
(
NodeTree
(
..
),
Tree
(
..
))
import
Gargantext.Database.Config
(
typeId2node
)
-- import Data.ByteString
--rename :: Connection -> NodeId -> Text -> IO ByteString
--rename conn nodeId name = formatQuery conn "UPDATE nodes SET name=? where id=?" (name,nodeId)
------------------------------------------------------------------------
type
NodeId
=
Int
type
Name
=
Text
type
ParentId
=
Int
data
Update
=
Rename
NodeId
Name
|
Move
NodeId
ParentId
-- | Update a Node
-- TODO : Field as parameter
-- TODO jsonb values, consider this:
-- https://stackoverflow.com/questions/26703476/how-to-perform-update-operations-on-columns-of-type-jsonb-in-postgres-9-4
update
::
Update
->
Connection
->
IO
[
Only
Int
]
update
(
Rename
nId
name
)
conn
=
query
conn
"UPDATE nodes SET name=? where id=? returning id"
(
DT
.
take
255
name
,
nId
)
update
(
Move
nId
pId
)
conn
=
query
conn
"UPDATE nodes SET parent_id= ? where id=? returning id"
(
pId
,
nId
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment