module JSDOM.Generated.IDBDatabase
(createObjectStore, createObjectStore_, createObjectStoreUnsafe,
createObjectStoreUnchecked, deleteObjectStore, transaction,
transaction_, transactionUnsafe, transactionUnchecked,
transaction', transaction'_, transaction'Unsafe,
transaction'Unchecked, close, getName, getVersion,
getObjectStoreNames, getObjectStoreNamesUnsafe,
getObjectStoreNamesUnchecked, abort, 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 Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, new, array)
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)
import JSDOM.Enums
createObjectStore ::
(MonadDOM m, ToJSString name, IsDictionary options) =>
IDBDatabase -> name -> Maybe options -> m (Maybe IDBObjectStore)
createObjectStore self name options
= liftDOM
((self ^. jsf "createObjectStore" [toJSVal name, toJSVal options])
>>= fromJSVal)
createObjectStore_ ::
(MonadDOM m, ToJSString name, IsDictionary options) =>
IDBDatabase -> name -> Maybe options -> m ()
createObjectStore_ self name options
= liftDOM
(void
(self ^. jsf "createObjectStore" [toJSVal name, toJSVal options]))
createObjectStoreUnsafe ::
(MonadDOM m, ToJSString name, IsDictionary options,
HasCallStack) =>
IDBDatabase -> name -> Maybe options -> m IDBObjectStore
createObjectStoreUnsafe self name options
= liftDOM
(((self ^. jsf "createObjectStore" [toJSVal name, toJSVal options])
>>= fromJSVal)
>>= maybe (Prelude.error "Nothing to return") return)
createObjectStoreUnchecked ::
(MonadDOM m, ToJSString name, IsDictionary options) =>
IDBDatabase -> name -> Maybe options -> m IDBObjectStore
createObjectStoreUnchecked self name options
= liftDOM
((self ^. jsf "createObjectStore" [toJSVal name, toJSVal options])
>>= fromJSValUnchecked)
deleteObjectStore ::
(MonadDOM m, ToJSString name) => IDBDatabase -> name -> m ()
deleteObjectStore self name
= liftDOM (void (self ^. jsf "deleteObjectStore" [toJSVal name]))
transaction ::
(MonadDOM m, ToJSString storeName, ToJSString mode) =>
IDBDatabase -> storeName -> mode -> m (Maybe IDBTransaction)
transaction self storeName mode
= liftDOM
((self ^. jsf "transaction" [toJSVal storeName, toJSVal mode]) >>=
fromJSVal)
transaction_ ::
(MonadDOM m, ToJSString storeName, ToJSString mode) =>
IDBDatabase -> storeName -> mode -> m ()
transaction_ self storeName mode
= liftDOM
(void
(self ^. jsf "transaction" [toJSVal storeName, toJSVal mode]))
transactionUnsafe ::
(MonadDOM m, ToJSString storeName, ToJSString mode,
HasCallStack) =>
IDBDatabase -> storeName -> mode -> m IDBTransaction
transactionUnsafe self storeName mode
= liftDOM
(((self ^. jsf "transaction" [toJSVal storeName, toJSVal mode]) >>=
fromJSVal)
>>= maybe (Prelude.error "Nothing to return") return)
transactionUnchecked ::
(MonadDOM m, ToJSString storeName, ToJSString mode) =>
IDBDatabase -> storeName -> mode -> m IDBTransaction
transactionUnchecked self storeName mode
= liftDOM
((self ^. jsf "transaction" [toJSVal storeName, toJSVal mode]) >>=
fromJSValUnchecked)
transaction' ::
(MonadDOM m, ToJSString storeNames, ToJSString mode) =>
IDBDatabase -> [storeNames] -> mode -> m (Maybe IDBTransaction)
transaction' self storeNames mode
= liftDOM
((self ^. jsf "transaction"
[toJSVal (array storeNames), toJSVal mode])
>>= fromJSVal)
transaction'_ ::
(MonadDOM m, ToJSString storeNames, ToJSString mode) =>
IDBDatabase -> [storeNames] -> mode -> m ()
transaction'_ self storeNames mode
= liftDOM
(void
(self ^. jsf "transaction"
[toJSVal (array storeNames), toJSVal mode]))
transaction'Unsafe ::
(MonadDOM m, ToJSString storeNames, ToJSString mode,
HasCallStack) =>
IDBDatabase -> [storeNames] -> mode -> m IDBTransaction
transaction'Unsafe self storeNames mode
= liftDOM
(((self ^. jsf "transaction"
[toJSVal (array storeNames), toJSVal mode])
>>= fromJSVal)
>>= maybe (Prelude.error "Nothing to return") return)
transaction'Unchecked ::
(MonadDOM m, ToJSString storeNames, ToJSString mode) =>
IDBDatabase -> [storeNames] -> mode -> m IDBTransaction
transaction'Unchecked self storeNames mode
= liftDOM
((self ^. jsf "transaction"
[toJSVal (array storeNames), toJSVal mode])
>>= fromJSValUnchecked)
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 (Maybe DOMStringList)
getObjectStoreNames self
= liftDOM ((self ^. js "objectStoreNames") >>= fromJSVal)
getObjectStoreNamesUnsafe ::
(MonadDOM m, HasCallStack) => IDBDatabase -> m DOMStringList
getObjectStoreNamesUnsafe self
= liftDOM
(((self ^. js "objectStoreNames") >>= fromJSVal) >>=
maybe (Prelude.error "Nothing to return") return)
getObjectStoreNamesUnchecked ::
(MonadDOM m) => IDBDatabase -> m DOMStringList
getObjectStoreNamesUnchecked self
= liftDOM ((self ^. js "objectStoreNames") >>= fromJSValUnchecked)
abort :: EventName IDBDatabase Event
abort = unsafeEventName (toJSString "abort")
error :: EventName IDBDatabase Event
error = unsafeEventName (toJSString "error")
versionChange :: EventName IDBDatabase IDBVersionChangeEvent
versionChange = unsafeEventName (toJSString "versionchange")