Hi,
I have 2 datasets: datasetItems, datasetProperties
I would like to LOOP THROUGH datasetItems and UPDATE datasetItems with proper Property from datasetProperties
For example datasetItems.items[itemID].Color= datasetProperties.items[itemID].Color
Please point me to proper example how to do it in Corvid!
@Chana Manhaimer Good to know.
FYI (adding this here in case anyone else looks at this post) - depending on the number of items you are dealing with this might slow your site rendering time down. The reason is that you are stopping processing every time you use the await keyword with a Promise based function. If you are using this code to update items in a UI then you may want to consider using the promise model in all of its Async glory so that you can do work in parallel.
Also calling wixData for each item twice in await mode is very slow. For better performance you may want to consider loading all of the data into memory and then map the Color information. You can use bulkUpdate to save the updated records. Remember each time you call a wixData api function you are performing a network operation that might be costly on a mobile device. Also every time you access the network you might encounter a failure so you might also want to think about adding code to catch exceptions if they hey occur so you don’t end up with corrupt data.
Cheers
Can you provide more context? For example if the data collections you are mapping are larger than the dataset page size and the properties are not in sync with the items then this won’t work consistently. For example if the items dataset contains the first 20 elements from the data collection and the properties dataset contains the second 20 records then your algorithm would assign the color from the data collection for properties row 20 to the color for data collection Items row 0. If you can share you data collections, how you want to use them and any existing code and bindings that will help get you a solution.