{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.Database
(changeVersion, transaction, readTransaction, getVersion,
Database(..), gTypeDatabase)
where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums
changeVersion ::
(MonadDOM m, ToJSString oldVersion, ToJSString newVersion) =>
Database ->
oldVersion ->
newVersion ->
Maybe SQLTransactionCallback ->
Maybe SQLTransactionErrorCallback -> Maybe VoidCallback -> m ()
changeVersion :: forall (m :: * -> *) oldVersion newVersion.
(MonadDOM m, ToJSString oldVersion, ToJSString newVersion) =>
Database
-> oldVersion
-> newVersion
-> Maybe SQLTransactionCallback
-> Maybe SQLTransactionErrorCallback
-> Maybe VoidCallback
-> m ()
changeVersion Database
self oldVersion
oldVersion newVersion
newVersion Maybe SQLTransactionCallback
callback Maybe SQLTransactionErrorCallback
errorCallback
Maybe VoidCallback
successCallback
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
(Database
self Database -> Getting (JSM JSVal) Database (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"changeVersion"
[oldVersion -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal oldVersion
oldVersion, newVersion -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal newVersion
newVersion, Maybe SQLTransactionCallback -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe SQLTransactionCallback
callback,
Maybe SQLTransactionErrorCallback -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe SQLTransactionErrorCallback
errorCallback, Maybe VoidCallback -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe VoidCallback
successCallback]))
transaction ::
(MonadDOM m) =>
Database ->
SQLTransactionCallback ->
Maybe SQLTransactionErrorCallback -> Maybe VoidCallback -> m ()
transaction :: forall (m :: * -> *).
MonadDOM m =>
Database
-> SQLTransactionCallback
-> Maybe SQLTransactionErrorCallback
-> Maybe VoidCallback
-> m ()
transaction Database
self SQLTransactionCallback
callback Maybe SQLTransactionErrorCallback
errorCallback Maybe VoidCallback
successCallback
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
(Database
self Database -> Getting (JSM JSVal) Database (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"transaction"
[SQLTransactionCallback -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal SQLTransactionCallback
callback, Maybe SQLTransactionErrorCallback -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe SQLTransactionErrorCallback
errorCallback,
Maybe VoidCallback -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe VoidCallback
successCallback]))
readTransaction ::
(MonadDOM m) =>
Database ->
SQLTransactionCallback ->
Maybe SQLTransactionErrorCallback -> Maybe VoidCallback -> m ()
readTransaction :: forall (m :: * -> *).
MonadDOM m =>
Database
-> SQLTransactionCallback
-> Maybe SQLTransactionErrorCallback
-> Maybe VoidCallback
-> m ()
readTransaction Database
self SQLTransactionCallback
callback Maybe SQLTransactionErrorCallback
errorCallback Maybe VoidCallback
successCallback
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
(Database
self Database -> Getting (JSM JSVal) Database (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"readTransaction"
[SQLTransactionCallback -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal SQLTransactionCallback
callback, Maybe SQLTransactionErrorCallback -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe SQLTransactionErrorCallback
errorCallback,
Maybe VoidCallback -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe VoidCallback
successCallback]))
getVersion ::
(MonadDOM m, FromJSString result) => Database -> m result
getVersion :: forall (m :: * -> *) result.
(MonadDOM m, FromJSString result) =>
Database -> m result
getVersion Database
self
= DOM result -> m result
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((Database
self Database -> Getting (JSM JSVal) Database (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter Database (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"version") JSM JSVal -> (JSVal -> DOM result) -> DOM result
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM result
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)