Hello! In my database (forexample "MyDatabase") there are several fields. For example title,
name,
order number I make filterSelection by "title". Input values for filtering. For example: One result - 10 records, another - 98
I put this numbers in variable "CountResult"
I need update database just put in field "orderNumbers" numbers from 1 to "CountResult" I do Query, read Results with selected filter
and run FOR (var i=0, I<CountResults, I++)
Inside do qwery.update
When I updating (10 rows records) It's working and updating
With 98 results - about 30 Errors, About 30 Rows not Updated
Each attemprs - give me different wrong rows and No Error Message, Just word :Error" Please advice me in such code. I repeat - Just make query, read result and change on columns - out in it numbers from 1 to "CountResult" Thank You in advance I do My code fragment: //SelectKey - selected filtering Item
// SongsCount - RealNumber, determined in code before
wixData.query("dbBardSongs") .eq("bardName", selectedKey) .limit(100) .find() .then( (results1) => { if(results1.items.length > 0) {
for (var i=0;i<SongsCount;i++) { toUpdate = { "_id": results1.items[i]._id, "title": results1.items[i].title, "bardName": results1.items[i].bardName, "firstLine": results1.items[i].firstLine, "orderNumber": i + 1 };
wixData.update("dbBardSongs", toUpdate) .then( (results2) => {
item = results2;
}; .catch( (err) => {
errorMsg = err; console.log("error Msg = " + errorMsg);
} );
} else { // handle case where no matching items found }
} ) .catch( (err) => {let errorMsg = err;} );
I look carefully on my code, Use real numbers instead identification and Deferentially see that Database Update "lost" (skip, drop) some rows during update if I update more then 20 rows one by one May be timeout of owerstok or or????
What is SongsCount and why not to use bulkUpdate in this case?