Commit 2604c7a4 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[DB] insert on conclict.

parent 1114fe2d
...@@ -32,7 +32,6 @@ import Gargantext.Database.Types.Node ...@@ -32,7 +32,6 @@ import Gargantext.Database.Types.Node
import Opaleye import Opaleye
data NodeNodeNgramsPoly n1 n2 ngrams_id ngt w data NodeNodeNgramsPoly n1 n2 ngrams_id ngt w
= NodeNodeNgrams { _nnng_node1_id :: n1 = NodeNodeNgrams { _nnng_node1_id :: n1
, _nnng_node2_id :: n2 , _nnng_node2_id :: n2
......
...@@ -35,12 +35,10 @@ Next Step benchmark: ...@@ -35,12 +35,10 @@ Next Step benchmark:
module Gargantext.Database.Schema.Node_NodeNgrams_NodeNgrams module Gargantext.Database.Schema.Node_NodeNgrams_NodeNgrams
where where
import Control.Lens (view)
import Control.Lens.TH (makeLensesWith, abbreviatedFields) import Control.Lens.TH (makeLensesWith, abbreviatedFields)
import Control.Monad.IO.Class (liftIO)
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Data.Profunctor.Product.TH (makeAdaptorAndInstance) import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
import Gargantext.Database.Utils (Cmd, runOpaQuery, connection) import Gargantext.Database.Utils (Cmd, runOpaQuery, mkCmd)
import Gargantext.Database.Types.Node (CorpusId) import Gargantext.Database.Types.Node (CorpusId)
import Gargantext.Database.Schema.Node (pgNodeId) import Gargantext.Database.Schema.Node (pgNodeId)
import Gargantext.Prelude import Gargantext.Prelude
...@@ -115,6 +113,10 @@ insert_Node_NodeNgrams_NodeNgrams = insert_Node_NodeNgrams_NodeNgrams_W ...@@ -115,6 +113,10 @@ insert_Node_NodeNgrams_NodeNgrams = insert_Node_NodeNgrams_NodeNgrams_W
) )
insert_Node_NodeNgrams_NodeNgrams_W :: [Node_NodeNgrams_NodeNgrams_Write] -> Cmd err Int64 insert_Node_NodeNgrams_NodeNgrams_W :: [Node_NodeNgrams_NodeNgrams_Write] -> Cmd err Int64
insert_Node_NodeNgrams_NodeNgrams_W ns = do insert_Node_NodeNgrams_NodeNgrams_W ns =
c <- view connection mkCmd $ \c -> runInsert_ c Insert { iTable = node_NodeNgrams_NodeNgrams_Table
liftIO $ runInsertMany c node_NodeNgrams_NodeNgrams_Table ns , iRows = ns
, iReturning = rCount
, iOnConflict = (Just DoNothing)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment