{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.IDBDatabase
(createObjectStore, createObjectStore_, deleteObjectStore,
transaction, transaction_, close, getName, getVersion,
getObjectStoreNames, abort, closeEvent, error, versionChange,
IDBDatabase(..), gTypeIDBDatabase)
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
createObjectStore ::
(MonadDOM m, ToJSString name) =>
IDBDatabase ->
name -> Maybe IDBObjectStoreParameters -> m IDBObjectStore
createObjectStore self name parameters
= liftDOM
((self ^. jsf "createObjectStore"
[toJSVal name, toJSVal parameters])
>>= fromJSValUnchecked)
createObjectStore_ ::
(MonadDOM m, ToJSString name) =>
IDBDatabase -> name -> Maybe IDBObjectStoreParameters -> m ()
createObjectStore_ self name parameters
= liftDOM
(void
(self ^. jsf "createObjectStore"
[toJSVal name, toJSVal parameters]))
deleteObjectStore ::
(MonadDOM m, ToJSString name) => IDBDatabase -> name -> m ()
deleteObjectStore self name
= liftDOM (void (self ^. jsf "deleteObjectStore" [toJSVal name]))
transaction ::
(MonadDOM m, IsStringOrStrings storeNames) =>
IDBDatabase ->
storeNames -> Maybe IDBTransactionMode -> m IDBTransaction
transaction self storeNames mode
= liftDOM
((self ^. jsf "transaction" [toJSVal storeNames, toJSVal mode]) >>=
fromJSValUnchecked)
transaction_ ::
(MonadDOM m, IsStringOrStrings storeNames) =>
IDBDatabase -> storeNames -> Maybe IDBTransactionMode -> m ()
transaction_ self storeNames mode
= liftDOM
(void
(self ^. jsf "transaction" [toJSVal storeNames, toJSVal mode]))
close :: (MonadDOM m) => IDBDatabase -> m ()
close self = liftDOM (void (self ^. jsf "close" ()))
getName ::
(MonadDOM m, FromJSString result) => IDBDatabase -> m result
getName self = liftDOM ((self ^. js "name") >>= fromJSValUnchecked)
getVersion :: (MonadDOM m) => IDBDatabase -> m Word64
getVersion self
= liftDOM (round <$> ((self ^. js "version") >>= valToNumber))
getObjectStoreNames ::
(MonadDOM m) => IDBDatabase -> m DOMStringList
getObjectStoreNames self
= liftDOM ((self ^. js "objectStoreNames") >>= fromJSValUnchecked)
abort :: EventName IDBDatabase Event
abort = unsafeEventName (toJSString "abort")
closeEvent :: EventName IDBDatabase CloseEvent
closeEvent = unsafeEventNameAsync (toJSString "close")
error :: EventName IDBDatabase Event
error = unsafeEventName (toJSString "error")
versionChange :: EventName IDBDatabase IDBVersionChangeEvent
versionChange = unsafeEventName (toJSString "versionchange")