indexedDB | A wrapper for indexedDB with transaction supprot | Storage library
kandi X-RAY | indexedDB Summary
kandi X-RAY | indexedDB Summary
A wrapper for indexedDB with transaction supprot.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of indexedDB
indexedDB Key Features
indexedDB Examples and Code Snippets
Community Discussions
Trending Discussions on indexedDB
QUESTION
I am packaging the data for my WebAssembly game using emcc --preload-file
command, which puts it into MEMFS and keeps it in RAM until the webpage is closed.
The game typically opens a file, reads it's contents, closes it, and never touches the file again, it is not using mmap
.
Would it be more memory efficient to download all game data into IndexedDB / Emscripten IDBFS on first launch? Does the web browser load the whole IndexedDB into RAM, does it free up RAM after the file in IDBFS was closed?
My target hardware is Safari on iPhone XS with 2GB RAM, and the game data is around 60 MB.
...ANSWER
Answered 2021-Jun-01 at 22:01As you mentioned, MEMFS is an in-memory "filesystem" and it works in any browser. IndexedDB is a proper database and it's optimal use-case is for storing large amounts of data (more than what can fit in RAM).
Often times when an app or website is loaded for the first time there's a lot of API calls, authentication, and other work that needs to be done. Doing this every time the application opens up is not optimal so IndexedDB can be used as a way to speed up repeated visits. This way, the latest app state could be stored in IndexedDB and the app can then sync in the background (see stale-while-revalidate).
If you think your game could benefit from this, then you could consider using it. If you think you could also do this would MEMFS, however, I would recommend that since IndexedDB has some nuances.
In the specific case of safari on IOS, you can't store blob
s in IndexedDB. You can, however, convert the blob
into an ArrayBuffer
but you'll also have to store the MIME type alongside the buffer in order to do the conversion correctly (since ArrayBuffer
doesn't have a MIME type but blob
does).
Writing to storage in IndexedDB may also fail. This could happen for a variety of reasons. Maybe the user is using private mode, or maybe they don't have enough disk space.
If the user clears their cache on their phone, the IndexedDB data may be cleared as well. You may need to handle this.
I've run into some of these errors in the past using IndexedDB and it can be a headache. I would recommend Memfs.
As for the implementation details of IDBFS, it may or may not remain constant across browsers and platforms. What I can say for sure, however, is that unless you are saving a lot of data that needs to be computed in your first application, try profiling memfs and if it works well enough, then you can stick with it.
QUESTION
We're using DexieJS as a wrapper around IndexedDb and are looking for a way to determine if the underlying DB schema changes. Worst case, this is a user deleting a table, or the entire DB, in the midst of using our application (unlikely? sure, but come on - users).
Alternately, does IndexedDb record anything like a "Last Modified" value? We could make that work if that was all we had available. Subscribable events would be better, though...
Does IndexedDb or Dexie support anything like this?
ANSWER
Answered 2021-Feb-15 at 22:06Schema changes have to go through a version upgrade in IndexedDB and there's an event "onversionchange" that is triggered whenever schema is altered. Dexie describe the event here: https://dexie.org/docs/Dexie/Dexie.on.versionchange.
If you want to be notified for normal non-schema changes like table.clear(), you should try the latest alpha version of dexie (3.1.0-alpha.8) that supports cross-window/worker table observation. See release notes for 3.1.0-alpha.1 or this blog post. In your case, you'd probably want to observe any change on entire table. To do that, use:
QUESTION
I want to check and update quantity of item in indexeddb store if it already exist. This how I current add item to the store using Dexie
...ANSWER
Answered 2021-Mar-13 at 13:08function addNfetch (itemdata) {
return db.table('cartitems').put(itemdata);
}
QUESTION
I am using following statement to import dart indexed db library in Flutter application:
...ANSWER
Answered 2021-May-11 at 16:36According to this issue: indexedDB blocked
indexedDB is blocked in flutter
you could use an alternative like idb_shim which is simply a wrapper for indexedDB API
QUESTION
Consider, I have an IndexedDB database with a composite key, e.g.: [prop1, prop2]
.
Is it possible to do a partial query where only one part of the key is known to return multiple records from the database?
This will be equivalent to the following SQL query:
SELECT * FROM table WHERE prop1 = 'foo'
OR:
SELECT * FROM table WHERE prop2 = 'bar'
I've tried to use getAll()
method, but it looks like it's expecting value for both parts of the key.
If it's not possible — what alternative could be considered instead?
...ANSWER
Answered 2021-May-26 at 20:43I'm still not sure if partial query is actually possible for the composite key, however, I've decided to switch to a different strategy:
The idea is to use auto-generated primary key for the store and then to create two separate indices for the prop1
and prop2
. This way, you can query both properties separately. This suits my use-case pretty well:
QUESTION
I want to store my API data in indexedDB of Browser. I would have tried local storage but it has a limit of 5MB but my JSON data is more than 7MB. I want to save in indexedDB for faster access. I want to save the whole data in the JSON format but don't know how to set the scheme of the indexed DB. The data fetched from the database is testData
...ANSWER
Answered 2021-May-18 at 18:30Follow these steps for good architecture and reusable components ( Sample project is created here ):-
1 ) Create one file lets just name it indexDB.js
QUESTION
I'm tryin to update mysql with data from IndexedDb.
I loop threw the IndexedDb and inset data to mysql.
When a ajax call is complete the loop should contineu.
But i get this error:
Uncaught DOMException: Failed to execute 'update' on 'IDBCursor': The transaction has finished.
I can se that the Ajax call returned success and mySql is updated.
But when it comes to update the IndexDb it returns error.
This is the code:
ANSWER
Answered 2021-May-12 at 14:46Do the ajax call before starting a transaction. You cannot mix async calls with ajax together with indexedDB transactions. IndexedDB transactions will automatically close very shortly after it detects there are no active requests in the transaction.
QUESTION
I am working on IndexedDB functionality in JS - i would like to add some custom jquery trigger event with object of IndexedDB upon success callback, not sure whether it is possible but when i test event fired but it doesn't pass IndexedDB object
...ANSWER
Answered 2021-May-11 at 13:34You are not using jQuery's event methods correctly. The handler accepts additional parameters for any custom data you send. So your handler should look like this:
QUESTION
I keep getting this message in the console:
Uncaught TypeError: Cannot read property 'transaction' of undefined.
I've tried deleting the DB, restarting live server, moving the add()
into the onsuccess, but I can't quite figure out what to do. This line seems ok to me: const transaction = DB.transaction(['crm'], 'readwrite');
other answers I've checked were confusing
ANSWER
Answered 2021-May-10 at 11:26I was able to create a new client by making some fixes. See I made some changes to your newClient.js file the main problem was even if we pass variable DB
to the function conectDB()
as an argument the only time it will get assigned a value is when the connection to the database is successful right? and this is the problem that the function createNewClient()
is executed before the connection to the database is successful so what we need to do is we need to call the function createNewClient()
after the connection to the database is successful
so we need to call the function createNewClient()
once the connection to the database is successful and one way of doing this is calling the function createNewClient()
inside of the onsuccess
method as I have done in the following code. I had to make some local changes to newClient.js
file but at least your problem is solved now and you can refactor the code later as you want.
Keep this thing in mind call createNewClient()
function once the connection to the database is successful.
QUESTION
Working on an app that uses the new(ish) File System Access API, and I wanted to save the fileHandles of recently loaded files, to display a "Recent Files..." menu option and let a user load one of these files without opening the system file selection window.
This article has a paragraph about storing fileHandles in IndexedDB and it mentions that the handles returned from the API are "serializable," but it doesn't have any example code, and JSON.stringify won't do it.
File handles are serializable, which means that you can save a file handle to IndexedDB, or call postMessage() to send them between the same top-level origin.
Is there a way to serialize the handle other than JSON? I thought maybe IndexedDB would do it automatically but that doesn't seem to work, either.
...ANSWER
Answered 2021-Jan-28 at 14:16Here is a minimal example that demonstrates how to store and retrieve a file handle (a FileSystemHandle
to be precise) in IndexedDB (the code uses the idb-keyval library for brevity):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install indexedDB
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page