{"id":22570542,"url":"https://github.com/truqu/purescript-indexeddb","last_synced_at":"2025-03-28T14:23:10.656Z","repository":{"id":58237369,"uuid":"94545150","full_name":"truqu/purescript-indexedDB","owner":"truqu","description":"An API wrapper around indexedDB","archived":false,"fork":false,"pushed_at":"2023-03-02T12:52:11.000Z","size":204,"stargazers_count":11,"open_issues_count":4,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-02T15:11:51.716Z","etag":null,"topics":["indexeddb","progressive-web-app","purescript","storage","web"],"latest_commit_sha":null,"homepage":null,"language":"PureScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/truqu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-16T13:12:19.000Z","updated_at":"2023-03-25T12:32:31.000Z","dependencies_parsed_at":"2023-02-01T02:31:18.828Z","dependency_job_id":null,"html_url":"https://github.com/truqu/purescript-indexedDB","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truqu%2Fpurescript-indexedDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truqu%2Fpurescript-indexedDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truqu%2Fpurescript-indexedDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truqu%2Fpurescript-indexedDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/truqu","download_url":"https://codeload.github.com/truqu/purescript-indexedDB/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246042849,"owners_count":20714316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["indexeddb","progressive-web-app","purescript","storage","web"],"created_at":"2024-12-08T01:09:34.672Z","updated_at":"2025-03-28T14:23:10.629Z","avatar_url":"https://github.com/truqu.png","language":"PureScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"PureScript IndexedDB [![](https://img.shields.io/badge/doc-pursuit-60b5cc.svg)](http://pursuit.purescript.org/packages/purescript-indexeddb) [![Build Status](https://travis-ci.org/truqu/purescript-indexedDB.svg?branch=master)](https://travis-ci.org/truqu/purescript-indexedDB)\n=====\n\nThis package offers complete bindings and type-safety upon the [IndexedDB API](https://w3c.github.io/IndexedDB).\n\n## Overview \n\nThe `IDBCore` and `IDBFactory` are the two entry points required to create and connect to an\nindexed database. From there, modules are divided such that each of them covers a specific IDB\ninterface. \n\nThey are designed to be used as qualified imports such that each method gets prefixed with a\nmenaingful namespace (e.g `IDBIndex.get`, `IDBObjectStore.openCursor` ...)\n\nHere's a quick example of what it look likes. \n```purescript\nmodule Main where\n\nimport Prelude\n\nimport Control.Monad.Aff                 (Aff, launchAff_)\nimport Control.Monad.Aff.Console         (CONSOLE, log)\nimport Control.Monad.Eff.Exception       (EXCEPTION)\nimport Control.Monad.Eff                 (Eff)\nimport Data.Maybe                        (Maybe(..), maybe)\n\nimport Database.IndexedDB.Core\nimport Database.IndexedDB.IDBFactory      as IDBFactory\nimport Database.IndexedDB.IDBDatabase     as IDBDatabase\nimport Database.IndexedDB.IDBObjectStore  as IDBObjectStore\nimport Database.IndexedDB.IDBIndex        as IDBIndex\nimport Database.IndexedDB.IDBTransaction  as IDBTransaction\nimport Database.IndexedDB.IDBKeyRange     as IDBKeyRange\n\n\nmain :: Eff (idb :: IDB, exception :: EXCEPTION, console :: CONSOLE) Unit\nmain = launchAff_ do\n  db \u003c- IDBFactory.open \"db\" Nothing { onBlocked       : Nothing\n                                     , onUpgradeNeeded : Just onUpgradeNeeded\n                                     }\n\n  tx    \u003c- IDBDatabase.transaction db [\"store\"] ReadOnly\n  store \u003c- IDBTransaction.objectStore tx \"store\"\n  (val :: Maybe String) \u003c-  IDBObjectStore.get store (IDBKeyRange.only 1)\n  log $ maybe \"not found\" id val\n\n\nonUpgradeNeeded :: forall e. Database -\u003e Transaction -\u003e { oldVersion :: Int } -\u003e Eff (idb :: IDB, exception :: EXCEPTION | e) Unit\nonUpgradeNeeded db _ _ = launchAff_ do\n  store \u003c- IDBDatabase.createObjectStore db \"store\" IDBDatabase.defaultParameters\n  _     \u003c- IDBObjectStore.add store \"patate\" (Just 1)\n  _     \u003c- IDBObjectStore.add store { property: 42 } (Just 2)\n  _     \u003c- IDBObjectStore.createIndex store \"index\" [\"property\"] IDBObjectStore.defaultParameters\n  pure unit\n```\n\n## Notes\n\n### Errors\nErrors normally thrown by the IDB\\* interfaces are wrapped in the `Aff` Monad as `Error` where\nthe `name` corresponds to the error's name (e.g. \"InvalidStateError\"). Pattern matching can\ntherefore be done on any error to handle specific errors thrown by the API.\n\n### Examples\nThe `test` folder contains a great amount of examples showing practical usage of the IDB\\*\ninterfaces. Do not hesitate to have a peek should you wonder how to use one of the module. The\nwrapper tries to keep as much as possible an API consistent with the original IndexedDB API.\nHence, it should be quite straightforward to translate any JavaScript example to a PureScript\none. \n\n## Changelog\n\n#### v3.0.0\n\n- callback to `onUpgradeNeeded` event now provide a record with the database old version.\n\n#### v2.0.0\n\n- review interface implementation (use of opaque classes to improve readability without compromising\n  the reusability). The API doesn't really change from a user perspective though.\n\n- make the Key more opaque (by having an IDBKey instance for Foreign types)\n\n- Upgrade purescript-exceptions to 3.1.0 and leverage the new `name` accessor\n\n\n#### v1.0.0\n\n- [Indexed Database API 2.0](https://w3c.github.io/IndexedDB/) totally covered apart from \n  - `index.getAll` method (and the associated one for the IDBObjectStore)\n  - binary keys\n\n## Documentation\n\nModule documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-indexeddb).\n\n## Testing \nTested in the cloud on multiple browsers and operating systems thanks to [BrowserStack](https://www.browserstack.com)\n\n\n| IE / Edge | Chrome | Firefox | Safari  | Opera | Android | iOS Safari |\n| ----------| ------ | ------- | ------- | ----- | ------- | ---------- |\n| -         | \u003e= 57  | \u003e= 51   | -       | \u003e= 46 | -       | -          |\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.browserstack.com\"\u003e\u003cimg alt=\"browserstack\" src=\".github/browserstack.png\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruqu%2Fpurescript-indexeddb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftruqu%2Fpurescript-indexeddb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruqu%2Fpurescript-indexeddb/lists"}