Dexie.js | A Minimalistic Wrapper for IndexedDB | Storage library
kandi X-RAY | Dexie.js Summary
kandi X-RAY | Dexie.js Summary
[NPM Version][npm-image]][npm-url] [Build Status] with Browserstack(Dexie.js is a wrapper library for indexedDB - the standard database in the browser.
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 Dexie.js
Dexie.js Key Features
Dexie.js Examples and Code Snippets
Community Discussions
Trending Discussions on Dexie.js
QUESTION
I am relatively new to web development and currently trying to work out an "offline" Application with vue.js and dexie.js. Dexie.js allows easier access on modern browsers Indexed Database.
Nontheless I believe my problem is more on the basic javascript side.
I got this basic DB("enhanced" with Dexie):
...ANSWER
Answered 2021-Mar-28 at 23:02You need to set app.tasks[i]
to an empty object at the beginning of each assignment in the loop:
QUESTION
I have a Dexie.js database with the table "businessLayers" in my React application. I'd like to ensure de data types of the tuples inserted in that table. I thought the method Table.defineClass() would do that, but it does not. My db is the following:
...ANSWER
Answered 2021-Mar-25 at 12:53Table.defineClass() was an old feature in Dexie 1.x for code completion only - no enforcements. The method should have been deprecated. But the functionality you need can be implemented using a DBCore middleware or creating/updating hooks. DBCore middlware would be the most performant solution as it does not need to verify existing data.
Below is a dry coded full example. Please test and reply if it works. It should support String, Number, Boolean, Array, Object, Set, Map, ArrayBuffer, Uint8Array, etc... and even custom classes. If anyone wants to make a package of this code, please go ahead! I think it could be a nice addon to dexie:
QUESTION
I have a question about indexedDB
and Dexie.js
library, for restoring and backing up databases and their performance improvements. lets imagine we have at least a 2 GB database (for offline map data) and they have a (key,value) structure which Key can be an string and value is blob (image or binary vector data).
So in my scenario users select a database and my web application should start to download that database for offline access. So what approach do you think gives me the best performance in this case? Since I have to download the backup and restore them and for 2GB and a few million records it can be a performance challenge. I have done similar thing before for sqlite databases but I only needed to download the db file and connect to it. Here I have to restore IndexedDB after downloading which seems to be problematic. So I can break my problem in several sub issues:
Firstly How can I make those databases in the first place?
And then, how can I restore those backups? Is there any high-performance method to do so?
Does the key data type (String or Integer) has effect on the performance of IndexedDB?
...ANSWER
Answered 2021-Mar-07 at 22:49I'm not sure what you mean with "restore" but I think you mean to import data into IndexedDB? Or did you mean that IndexedDB is the backup and "restore" for putting it back into another database?
I base the rest of my answer on the assumption that "restore" is importing data into indexeddb.
The only way to know how the system would perform when adding millions of key/value (blob) based rows would be to test it. I would suggest you import the rows in chunks of maybe 1000 each and show a progress bar for each imported chunk. Use bulkAdd() or bulkPut() methods to import each chunk. Make sure not to do the entire import in a single transaction because that could probably starve the system and block indexeddb for too long. But by using the bulk-methods each chunk would use a single transaction at least (which is also important - one transaction per 1000 records would probably be fine - but if you test this, try different chunk sizes to find the optimal speed!).
Also don't know what the user can expect in terms of waiting time. Can it be performed in the background while user can use your app in online mode? If so, it the user could probably accept longer import-time than if the user would have to wait for the entire data to be imported.
You would also need to look at the StorageManager API and ask your user for permission to store large amounts of durable data. You can read page about it in dexie docs also.
You would probably want a background worker to fetch the data and perform the bulk operations - create a service worker that does the job. Either use response.blob() and pass it to dexie-export-import. You could also try the ReadableStream api to download chunks of data. Letting a worker do this download and import will perform faster and not affect the application performance while importing.
Dexie-export-import does almost exactly what I am suggesting here - imports the rows in chunks into indexeddb, but if using it you would need to let your service endpoint send JSON that is compatible with dexie-export-import where blobs are Baset64 encoded. But since your data is only keys and blobs, you could benefit from having your own binary format and do the bulkAdd() yourself without this addon.
Regarding your last question: to my knowledge, there wouldn't be so much difference between using number or strings as keys. Long strings would be slower but short strings probably perform equal to numbers (correct me someone if this isn't true!). You would need to test to really know.
If you will perform some test on this, please let me know what your results were ;)
QUESTION
I am trying get a value from indexedDB with Dexie.js but it does not recognize the value from localStorage.
I tried async/await, promises, placing localstorage call on created, mounted, outside export default, and none of these ways worked.
...ANSWER
Answered 2021-Feb-01 at 04:53.equals
strict equality
The equals
method is a strict equality test, so if id
is a number type in indexedDB
, then the string type returned from localStorage
won't match, because of the different types. And localStorage
only stores strings.
For this reason, it's common to see JSON.parse
used when retrieving data from localStorage
, to convert serialized data :
QUESTION
I'm using Dexie.js version 3.0.3-rc.3
in a Vue JS project and I occasionally run into this exception in Chrome (86):
Failed to execute 'bound' on 'IDBKeyRange': The parameter is not a valid key.↵ DataError: Failed to execute 'bound' on 'IDBKeyRange': The parameter is not a valid key.
Here's a screenshot of the full error:
I'm fairly certain the problem lies with something in my data being undefined
, but I'm trying to find a good way to troubleshoot this. I paused the Chrome dev tools on exceptions and inspected the code around this particular part of Dexie, but it doesn't reveal what data was used to make this exception occur.
Does anyone have any suggestions on how to find out what's actually wrong? It feels a bit like a needle in a haystack.
== Update ==
Below is the full call stack:
...ANSWER
Answered 2020-Oct-23 at 07:04Try inspecting the call stack. I know it can be long until you reach a frame within your application code, but the failing call should be there!
QUESTION
I'm having some troubles getting where() statements to work in Dexie. My attempts to use where result in the following error:
...ANSWER
Answered 2020-Oct-22 at 08:58I think you're missing to set Dexie.dependencies.IDBKeyRange also.
Fake-indexeddb recommends to do the following to integrate fake-indexeddb in node:
QUESTION
I have a function that fetch a JSON data via window.fetch
and put it inside IndexedDB
table via db.table.bulkPut(array_of_data)
.
It takes more than 10 seconds to do that because of large amount of data and it blocks UI and makes UX bad.
I have decided to run this task in a Worker
, but I have not found any examples how can I make that with Dexie.js or directly with IndexedDB
Thank you for any advice :)
...ANSWER
Answered 2020-Jul-28 at 07:02Thank you @kaiido for link this is an answer -=> https://github.com/dfahlander/Dexie.js/issues/789
QUESTION
I am trying to delete a record by ID from indexedDB using dexie.js. (Dexie.js is a wrapper for indexedDB)
...ANSWER
Answered 2020-Jul-23 at 00:51Please let your promise-using functions return a promise so you can chain the calls to them.
Regarding calling delete within Collection.each(), it is not possible because Collection.each() is readonly unless you call it from a readwrite transaction. If you want to modify things within the iteration, use Collection.modify() instead of Collection.each(). This is described in the Notes section for Collection.each: https://dexie.org/docs/Collection/Collection.each()#notes
QUESTION
How can I build a function which gets some data asynchronously then uses that data to get more asynchronous data?
I am using Dexie.js (indexedDB wrapper) to store data about a direct message. One thing I store in the object is the user id which I'm going to be sending messages to. To build a better UI I'm also getting some information about that user such as the profile picture, username, and display name which is stored on a remote rdbms. To build a complete link component in need data from both databases (local indexedDB and remote rdbms).
My solution returns an empty array. It is being computed when logging it in Google Chrome and I do see my data. However because this is not being computed at render time the array is always empty and therefor I can't iterate over it to build a component.
...ANSWER
Answered 2020-May-10 at 15:47Please set receivers initial value as array
QUESTION
I have this vue.js instance that is managing the DOM of an electron app. I need to take the app UI updated, what is the app now doing is doing some calculations and then display the result. A save button will instruct the app to save the input info and the result of the calculations. What I'm trouble with is the DOM update. After I hit the save button, I need that the table that s displaying the data will refresh to show the new added row and show data into a chart. For the chart I didn't implemented it yet, I need help on how to format the dataset, for the rest, the table will not refresh for now.
I'm using Dexie.js and I have chart.js as a dependency of the project.
...ANSWER
Answered 2020-Mar-28 at 09:14To make a value or object reactive in Vue it needs to be initialised properly, generally this is either as a prop
, a data
property or a computed
value.
Vue is not seeing changes to your db
variable because it hasn't been initialised as one of these.
For an array of table data you can initialise it like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Dexie.js
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