.gitignore | ||
LICENSE | ||
README.md |
API
This document is a general grooming of the current state of the IndexedDB API. It covers only the features specified in the official specs.
Remarks
-
Better define a 'all' range instead of using Maybe
IDBKeyRange
in function signatures (Nothing meaning 'all'). -
Some errors (like TypeError or DataError) can be avoided via static typing
-
The
IDBRequest
is mostly a callback result holding an error or a value. We probably want to use a typed Except or ExceptT instead.
Table of Contents
- IDBCursor
- IDBCursorWithValue
- IDBCursorDirection
- IDBDatabase
- IDBError
- IDBFactory
- IDBIndex
- IDBKeyRange
- IDBRequest
- IDBOpenDBRequest
- IDBObjectStore
- IDBTransaction
- IDBTransactionMode
IDBCursor
- source :: IDBIndex, IDBObjectStore
- direction :: IDBCursorDirection
- key :: IDBKey
- primaryKey :: IDBKey
- value :: Any
- advance :: IDBCursor -> Int -> ()
throw
TransactionInactiveError, TypeError, InvalidStateError - continue :: IDBCursor -> Maybe IDBKey -> ()
throw
TransactionInactivError, DataError, InvalidStateError - continuePrimaryKey :: IDBCursor -> IDBKey -> IDBKey -> ()
throw
TransactionInactiveError, DataError, InvalidStateError, InvalidAccessError
IDBCursorWithValue
https://developer.mozilla.org/en-US/docs/Web/API/IDBCursorwithValue
Inherit from IDBCursor
- delete :: IDBCursor -> IDBRequest ()
throw
TransactionInactiveError, ReadOnlyError, InvalidStateError - update :: IDBCursor -> a -> IDBRequest a
throw
TransactionInactiveError, ReadOnlyError, InvalidStateError, DataError, DataCloneError
IDBCursorDirection
data IDBCursorDirection = Next | NextUnique | Prev | PrevUnique
IDBDatabase
- name :: String
- version :: Long
- objectStoreNames :: [String]
- close :: IDBDatabase -> ()
- createObjectStore :: IDBDatabase -> String -> { keyPath :: String, autoIncrement :: Bool } -> IDBObjectStore
throw
InvalidStateError, TransactionInactiveError, ConstraintError, InvalidAccessError - deleteObjectStore :: IDBDatabase -> String -> ()
throw
InvalidSateError, TransactionInactiveError, NotFoundError - transaction :: IDBDatabase -> [String] -> IDBTransactionMode -> IDBTransaction
throw
InvalidStateError, NotFoundError, TypeError, InvalidAccessError
Events
- onabort
- onerror
- onversionchange
IDBError
data IDBError = AbortError | ConstraintError | QuotaExceededError | UnknownError | NoError | VersionError
IDBFactory
The method cmp
isn't included; instead, we consider IDBKey to be comparable.
- open :: String -> Maybe Long -> IDBOpenDBRequest ()
- deleteDatabase :: String -> IDBOpenDBRequest ()
IDBIndex
https://www.w3.org/TR/IndexedDB/#index-concept
https://www.w3.org/TR/IndexedDB/#index
- name :: String
- objectStore :: IDBObjectStore
- keyPath :: String
- multiEntry :: Bool
- unique :: Bool
- count :: IDBIndex -> Maybe IDBKeyRange -> IDBRequest Int
throw
TransactionInactiveError, DataError, InvalidStateError - get :: IDBIndex -> IDBKeyRange -> IDBRequest a
throw
TransactionInactiveError, DataError, InvalidStateError - getKey :: IDBIndex -> IDBKeyRange -> IDBRequest IDBKey
throw
TransactionInactiveError, DataError, InvalidStateError - openCursor :: IDBIndex -> Maybe IDBKeyRange -> Maybe Direction -> IDBRequest CursorWithValue
throw
TransactionInactiveError, DataError, TypeError, InvalidStateError - openKeyCursor :: IDBIndex -> Maybe IDBKeyRange-> Maybe Direction -> IDBRequest Cursor
throw
TransactionInactiveError, DataError, TypeError, InvalidStateError
IDBKey
Should be comparable / derive Ord
data IDBKey = Int Int | Float Float | String String | Date Date | Array [IDBKey]
IDBKeyRange
- lower :: IDBKey
- upper :: IDBKey
- lowerOpen :: Boolean
- upperOpen :: Boolean
- bound :: IDBKey -> IDBKey -> Bool -> Bool -> IDBKeyRange
throw
DataError - only :: IDBKey -> IDBKeyRange
throw
DataError - lowerBound :: IDBKey -> Bool -> IDBKeyRange
throw
DataError - upperBound :: IDBKey -> Bool -> IDBKeyRange
throw
DataError - includes :: IDBKey -> Boolean
throw
DataError
IDBRequest
- error :: IDBError
- result :: a
- source :: IDBIndex | IDBObjectStore | IDBCursor
- readyState :: Bool
- transaction :: Maybe IDBTransaction
Events
- onerror
- onsuccess
IDBOpenDBRequest
Inherit from IDBRequest
Events
- onblocked
- onupgradeneeded
IDBObjectStore
- indexNames:: [String]
- keyPath :: String
- name :: String
- transaction :: IDBTransaction
- autoIncrement :: Bool
- add :: IDBObjectStore -> Value -> Maybe IDBKey -> IDBRequest ()
throw
ReadOnlyError, TransactionInactiveError, DataError, InvalidStateError, DataCloneError - clear :: IDBObjectStore -> IDBRequest ()
throw
ReadOnlyError, TransactionInactiveError - count :: IDBObjectStore -> IDBKeyRange -> IDBRequest Int
throw
InvalidStateError, TransactionInactiveError, DataError - createIndex :: IDBObjectStore -> String -> String -> { unique :: Bool, multiEntry :: true } -> IDBIndex
throw
ConstraintError, InvalidAccessError, InvalidStateError, SyntaxError, TransactionInactiveError - delete :: IDBObjectStore -> IDBKeyRange -> IDBRequest ()
throw
TransactionInactiveError, ReadOnlyError, InvalidStateError, DataError - deleteIndex :: IDBObjectStore -> String -> ()
throw
InvalidStateError, TransactionInactiveError, NotFoundError - get :: IDBObjectStore -> IDBKeyRange -> IDBRequest a
throw
InvalidStateError, TransactionInactiveError, DataError - index :: IDBObjectStore -> String -> IDBIndex
throw
InvalidStateError, NotfoundError - openCursor :: IDBObjectStore -> Maybe IDBKeyRange -> Maybe IDBCursorDirection -> IDBRequest IDBCursorWithValue
throw
TransactionInactiveError, InvalidStateError, DataError - put :: IDBObjectStore -> a -> IDBKey -> IDBRequest ()
throw
ReadOnlyError, TransactionInactiveError, DataError, InvalidStateError, DataCloneError
IDBTransaction
- db :: IDBDatabase
- error :: IDBError
- mode :: IDBTransactionMode
- abort :: IDBTransaction -> ()
throw
InvalidStateError - objectStore :: IDBTransaction -> String -> IDBObjectStore
throw
InvalidStateError, NotFoundError
Events
- onabort
- oncomplete
- onerror
IDBTransactionMode
data IDBTransactionMode = ReadOnly | ReadWrite | VersionChange