packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/IDBDatabase.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from IndexedDB-3 (webref). Do not edit.
module JSDOM.Generated.IDBDatabase
       (close, createObjectStore, createObjectStore_, deleteObjectStore, transaction, transaction_, transaction', transaction'_, getName, getVersion, getObjectStoreNames, abort, closeEvent, error, versionChange, IDBDatabase(..), gTypeIDBDatabase)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums

-- | <https://developer.mozilla.org/docs/Web/API/IDBDatabase/close MDN IDBDatabase.close documentation>
close :: (MonadDOM m) => IDBDatabase -> m ()
close self = liftDOM (void (self ^. jsf "close" ()))

-- | <https://developer.mozilla.org/docs/Web/API/IDBDatabase/createObjectStore MDN IDBDatabase.createObjectStore documentation>
createObjectStore :: (MonadDOM m, ToJSString name) => IDBDatabase -> name -> Maybe IDBObjectStoreParameters -> m IDBObjectStore
createObjectStore self name options = liftDOM (((self ^. jsf "createObjectStore" [toJSVal name, P.maybe (P.return jsUndefined) toJSVal options]) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/IDBDatabase/createObjectStore MDN IDBDatabase.createObjectStore documentation>
createObjectStore_ :: (MonadDOM m, ToJSString name) => IDBDatabase -> name -> Maybe IDBObjectStoreParameters -> m ()
createObjectStore_ self name options = liftDOM (void (self ^. jsf "createObjectStore" [toJSVal name, P.maybe (P.return jsUndefined) toJSVal options]))

-- | <https://developer.mozilla.org/docs/Web/API/IDBDatabase/deleteObjectStore MDN IDBDatabase.deleteObjectStore documentation>
deleteObjectStore :: (MonadDOM m, ToJSString name) => IDBDatabase -> name -> m ()
deleteObjectStore self name = liftDOM (void (self ^. jsf "deleteObjectStore" [toJSVal name]))

-- | <https://developer.mozilla.org/docs/Web/API/IDBDatabase/transaction MDN IDBDatabase.transaction documentation>
transaction :: (MonadDOM m, IsStringOrSequenceString storeNames) => IDBDatabase -> storeNames -> Maybe IDBTransactionMode -> m IDBTransaction
transaction self storeNames mode = liftDOM (((self ^. jsf "transaction" [toJSVal storeNames, P.maybe (P.return jsUndefined) toJSVal mode]) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/IDBDatabase/transaction MDN IDBDatabase.transaction documentation>
transaction_ :: (MonadDOM m, IsStringOrSequenceString storeNames) => IDBDatabase -> storeNames -> Maybe IDBTransactionMode -> m ()
transaction_ self storeNames mode = liftDOM (void (self ^. jsf "transaction" [toJSVal storeNames, P.maybe (P.return jsUndefined) toJSVal mode]))

-- | <https://developer.mozilla.org/docs/Web/API/IDBDatabase/transaction MDN IDBDatabase.transaction documentation>
transaction' :: (MonadDOM m, IsStringOrSequenceString storeNames) => IDBDatabase -> storeNames -> Maybe IDBTransactionMode -> Maybe IDBTransactionOptions -> m IDBTransaction
transaction' self storeNames mode options = liftDOM (((self ^. jsf "transaction" [toJSVal storeNames, P.maybe (P.return jsUndefined) toJSVal mode, P.maybe (P.return jsUndefined) toJSVal options]) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/IDBDatabase/transaction MDN IDBDatabase.transaction documentation>
transaction'_ :: (MonadDOM m, IsStringOrSequenceString storeNames) => IDBDatabase -> storeNames -> Maybe IDBTransactionMode -> Maybe IDBTransactionOptions -> m ()
transaction'_ self storeNames mode options = liftDOM (void (self ^. jsf "transaction" [toJSVal storeNames, P.maybe (P.return jsUndefined) toJSVal mode, P.maybe (P.return jsUndefined) toJSVal options]))

-- | <https://developer.mozilla.org/docs/Web/API/IDBDatabase/name MDN IDBDatabase.name documentation>
getName :: (MonadDOM m, FromJSString result) => IDBDatabase -> m result
getName self = liftDOM (((self ^. js "name") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/IDBDatabase/version MDN IDBDatabase.version documentation>
getVersion :: (MonadDOM m) => IDBDatabase -> m Word53
getVersion self = liftDOM (((self ^. js "version") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/IDBDatabase/objectStoreNames MDN IDBDatabase.objectStoreNames documentation>
getObjectStoreNames :: (MonadDOM m) => IDBDatabase -> m DOMStringList
getObjectStoreNames self = liftDOM (((self ^. js "objectStoreNames") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/IndexedDB/#dom-idbdatabase-onabort abort event>
abort :: EventName IDBDatabase Event
abort = unsafeEventName (toJSString "abort")

-- | <https://w3c.github.io/IndexedDB/#dom-idbdatabase-onclose close event>
closeEvent :: EventName IDBDatabase Event
closeEvent = unsafeEventNameAsync (toJSString "close")

-- | <https://w3c.github.io/IndexedDB/#dom-idbdatabase-onerror error event>
error :: EventName IDBDatabase Event
error = unsafeEventName (toJSString "error")

-- | <https://w3c.github.io/IndexedDB/#dom-idbdatabase-onversionchange versionchange event>
versionChange :: EventName IDBDatabase IDBVersionChangeEvent
versionChange = unsafeEventName (toJSString "versionchange")