IndexedDB.res

 1// IndexedDB bindings for route GeoJSON cache
 2
 3type database
 4
 5type objectStore
 6
 7type transaction
 8
 9type request<'a>
10
11// Access the global indexedDB object
12@val external indexedDB: 'a = "indexedDB"
13
14@new external makeRequest: unit => request<'a> = "IDBRequest"
15
16@get external result: request<'a> => 'a = "result"
17
18@set external onsuccess: (request<'a>, unit => unit) => unit = "onsuccess"
19
20@set external onerror: (request<'a>, unit => unit) => unit = "onerror"
21
22@set external onupgradeneeded: (request<'a>, unit => unit) => unit = "onupgradeneeded"
23
24@send external openDB: ('a, string, int) => request<database> = "open"
25
26@send external createObjectStore: (database, string, {"keyPath": string}) => objectStore = "createObjectStore"
27
28@send external transaction: (database, string, string) => transaction = "transaction"
29
30@send external objectStore: (transaction, string) => objectStore = "objectStore"
31
32@send external get: (objectStore, string) => request<'a> = "get"
33
34// Put with explicit key (when no keyPath defined)
35@send external putWithKey: (objectStore, JSON.t, string) => request<unit> = "put"
36
37// Put without explicit key (when keyPath is defined on the object store)
38@send external put: (objectStore, JSON.t) => request<unit> = "put"
39
40@get external error: request<'a> => Nullable.t<JsExn.t> = "error"