How do I approach working with IndexedDB through a Mint app? #792
Unanswered
jiggneshhgohel
asked this question in
Q&A
Replies: 1 comment 1 reply
-
There are no bindings for IndexedDB yet. You will need to create them on your own and for that you need to fall back to JavaScript using inlining: module IndexedDB {
fun open(name : String) : Promise(Result(String, IndexedDB) {
`
new Promise((resolve) {
const request = window.indexedDB.open(#{name});
request.onerror = (event) => {
resolve(#{Result.Err("Couldn't connect to database!")})
};
request.onsuccess = (event) => {
resolve(#{Result.Ok(`event.target.result`)})
};
})
`
}
}
// Later...
case IndexedDB.open("test") {
Ok(db) => // Do something with the database
Err(error) => // Couldn't open the database
} That ⬆️ should help you get started. The Also, here is the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am interested in implementing a Mint app abstracting an API demonstrated at https://www.javascripttutorial.net/web-apis/javascript-indexeddb/ to work with IndexedDB. How do I start with? I tried following
source/Stores/Database.mint
source/Routes.mint
but encountering following error which I am unable to understand how to fix:
I would like to expose an API like
Note: I am not seeking here any step-by-step help to achieve the desired goal. I am only seeking guidance on how to translate the demonstrated vanilla JS code into Mint lang syntax.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions