Question:
Hello everybody, I’m new on this site, so here my problem, and hope will be solved. Thanks in advance.
I would like to update 2 fields in my database called "Commandes Clients " by clicking on a button (First field : “Total panier” and second field “TotalpanierTXT” (There is an error in my code in attchment, but don’t worry, the code on my page is good about the 2 fields withe the good names)
For the first one, no pb, the field is updated. but not the second one… Why?
If I remove the first one, the second one works … and vice versa.
But not both together. Where is my mistake please? (See the code in attachment)
Product:
WIX EDITOR
What are you trying to achieve:
Update 2 fields after modifying them in a form.
Thanks everybody…
Hi, user3410 !!
I believe updating the collection simultaneously is not a good pattern, so I think it’s better to add await
before wixData.bulkUpdate()
to handle the process synchronously. The idea is to finish one process and then move on to the next one step by step.
like this…
// ...
.then(async(results) => {
// ...
await wixData.bulkUpdate("some", some); // 1
await wixData.bulkUpdate("some", some); // 2
// ...
});
Hi OneMoretime, thanks for your answer, but I’ve still got the pb. Did I make a mistake according to you in the code below :
I have a fundamental question. I’ve been reading your code carefully, and it seems that you are changing the same property of the same item in the array twice in succession. If that’s the case, wouldn’t the result of the latter execution overwrite the former one?
What is the reason for attempting to update the “totalPanier” field in two separate steps?
Reading your question, it seems like you want to “update two fields at the same time,” but it appears that there is only the “totalPanier” field. Is there another field name that I might be missing? Additionally, even if there are two field names, you don’t need to perform a bulkUpdate in two separate steps. You can simply replace both fields simultaneously using map.
{ ...item, totalPanier1: newValue1, totalPanier2: newValue2 }
1 Like
No, 2 fields… In the first attachement, there is an error in my code. But look in the second one : the 2 fields a different
Look below :
hey, the second solution you gave me is OK
the 2 fields a updated. Thank you very much for your help…
The code in attachment
1 Like
Oh, you’re right. I missed. I’m glad it worked out in the end! Enjoy Wix !!
1 Like