An API wrapper around indexedDB
Go to file
2017-06-29 11:23:05 +02:00
src implement binding for IDBCursor 2017-06-29 11:22:24 +02:00
test rename Key -> KeyPath & complete methods binding of IDBObjectStore 2017-06-23 21:39:31 +02:00
.eslintignore write specs for IDBFactory 2017-06-23 13:13:12 +02:00
.eslintrc remove Synchronous / Asynchronous type and pass fromMaybe as dependency 2017-06-23 10:34:32 +02:00
.gitignore initiate karma test runner 2017-06-23 10:20:39 +02:00
bower.json define Key type and implement serialization for Int, String, Date and Array of those 2017-06-23 18:12:59 +02:00
index.html initialize the purescript project 2017-06-22 14:20:27 +02:00
karma.conf.js write specs for IDBFactory 2017-06-23 13:13:12 +02:00
LICENSE Initial commit 2017-06-16 15:12:20 +02:00
package.json write 'start' script for dev using entr (pulp watcher doesn't do well with recursive watch in nested dirs 2017-06-29 11:23:05 +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