rvv041 - Insert and edit an address book entry functions created
address field in address book changed to T.Text
This commit is contained in:
parent
2fb6747bfb
commit
e9e56453c1
1 changed files with 20 additions and 1 deletions
|
@ -249,7 +249,7 @@ share
|
|||
AddressBook
|
||||
network ZcashNetDB
|
||||
descrip T.Text
|
||||
address HexStringDB
|
||||
address T.Text
|
||||
UniqueABA address
|
||||
deriving Show Eq
|
||||
|]
|
||||
|
@ -1484,5 +1484,24 @@ getAdrBook pool n =
|
|||
where_ (adrbook ^. AddressBookNetwork ==. val (ZcashNetDB n))
|
||||
pure adrbook
|
||||
|
||||
-- | Save a new address into AddressBook
|
||||
saveAdrsInAdrBook ::
|
||||
ConnectionPool -- ^ The database path to use
|
||||
-> AddressBook -- ^ The address to add to the database
|
||||
-> IO (Maybe (Entity AddressBook))
|
||||
saveAdrsInAdrBook pool a =
|
||||
runNoLoggingT $
|
||||
PS.retryOnBusy $ flip PS.runSqlPool pool $ insertUniqueEntity a
|
||||
|
||||
-- | Update an existing address into AddressBook
|
||||
updateAdrsInAdrBook :: ConnectionPool -> T.Text -> AddressBookId -> IO ()
|
||||
updateAdrsInAdrBook pool a i = do
|
||||
runNoLoggingT $
|
||||
PS.retryOnBusy $
|
||||
flip PS.runSqlPool pool $ do
|
||||
update $ \ab -> do
|
||||
set ab [AddressBookAddress =. val a]
|
||||
where_ $ ab ^. AddressBookId ==. val i
|
||||
|
||||
rmdups :: Ord a => [a] -> [a]
|
||||
rmdups = map head . group . sort
|
||||
|
|
Loading…
Reference in a new issue