Closed DAmrGharieb closed 1 year ago
Why is "no loops" a requirement?
For loop take alot of time i think i miss something
Nah, the type of loop is very rarely the performance problem, it's almost always what's inside the loop that causes performance issues.
// Let's say you had a database like this:
const db = await openDB('Articles', 1, {
upgrade(db) {
// Create a store of objects
const store = db.createObjectStore('articles', {
// The 'id' property of the object will be the key.
keyPath: 'id',
});
},
});
// And you had an array of articles:
const articles = [
// …articles…
];
// I'd add them all like this:
const tx = db.transaction('articles', 'readwrite');
await Promise.all(articles.map((article) => tx.store.add(article)));
await tx.done;
hi team good day is there is any solution if i have an array and i want to bulk insert them one time without looping
thanks