So I've looked around the forums and have found people with similar issues but cannot find exactly how they were able to solve this problem. I know using code is the way the solution can be accoplished but I am VERY new to wix code and I havent be able to figure out how to correctly move data between two databases on a button click. I'll describe what I am trying to accomplish:
I have "Database1" that contains items and their information. This database is used in the repeater to display all of the items in the collection. I also have "Database2" this is a database containing items that the user will have selected. What i am attempting to do, is have the data for an individual item in the repeater (from Database1) be copied into "Database2" when i click an "Add" button on the repeater.
I've played around with some code on this and even looked at some solutions others have come up with for similar issues but I cant seem to get this to work. Any help is greatly appreciated.
Thanks
Thank you! I'm going to take this and play around with it to see if i can get it to work. Thanks for the links too!
Hello,
The code would look something like this:
import wix-data from wixData; //import wix-data module to work with databases $w.onReady(async () => { $w('#button1').onClick(() => { //On button click let toInsert = $w('#dataset1').getCurrentItem(); //We get current item from dataset await wixData.insert('Database2', toInsert); //And insert it into database 2 )}; });
Here are the documentation pages that will help you:
inserting into collection
onClick event
getting current item from dataset
Goodluck!
Majd