An API wrapper around indexedDB
Go to file
2017-06-16 16:35:58 +02:00
.gitignore Initial commit 2017-06-16 15:12:20 +02:00
LICENSE Initial commit 2017-06-16 15:12:20 +02:00
README.md collect and groom informations on the API specifications 2017-06-16 16:35:58 +02:00

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

https://developer.mozilla.org/en-US/docs/Web/API/IDBCursor


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

https://www.w3.org/TR/IndexedDB/#idl-def-IDBCursorDirection

data IDBCursorDirection = Next | NextUnique | Prev | PrevUnique


IDBDatabase

https://www.w3.org/TR/IndexedDB/#idl-def-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

https://www.w3.org/TR/IndexedDB/#exceptions

data IDBError = AbortError | ConstraintError | QuotaExceededError | UnknownError | NoError | VersionError


IDBFactory

https://www.w3.org/TR/IndexedDB/#idl-def-IDBFactory

The method cmp isn't included; instead, we consider IDBKey to be comparable.


IDBIndex

https://www.w3.org/TR/IndexedDB/#index-concept
https://www.w3.org/TR/IndexedDB/#index


IDBKey

https://www.w3.org/TR/IndexedDB/#key-construct

Should be comparable / derive Ord

data IDBKey = Int Int | Float Float | String String | Date Date | Array [IDBKey]


IDBKeyRange

https://www.w3.org/TR/IndexedDB/#idl-def-IDBKeyRange


IDBRequest

https://www.w3.org/TR/IndexedDB/#idl-def-IDBRequest

Events
  • onerror
  • onsuccess

IDBOpenDBRequest

https://www.w3.org/TR/IndexedDB/#idl-def-IDBRequest

Inherit from IDBRequest

Events
  • onblocked
  • onupgradeneeded

IDBObjectStore

https://www.w3.org/TR/IndexedDB/#idl-def-IDBObjectStore


IDBTransaction

https://www.w3.org/TR/IndexedDB/#idl-def-IDBTransaction

Events
  • onabort
  • oncomplete
  • onerror

IDBTransactionMode

https://www.w3.org/TR/IndexedDB/#idl-def-IDBTransactionMode

data IDBTransactionMode = ReadOnly | ReadWrite | VersionChange