Shan
June 12, 2018, 4:49am
1
I have multiple items in a repeater and I want to add them to a database together
While I am able to insert them click by click (one item per click) I want to be able to add all of them with one click
Using this but to no avail:
export async function send_click(event, $w) {
let toInsert = $w("#dataset1").getCurrentItem();
while ($w("#dataset1").getCurrentItem());
await wixData.insert("SurveysSent", toInsert) //inserts the item
.then( (results) => {
console.log("done adding item")
} )
.catch( (err) => {
let errorMsg = err;
} );
}
Hey shan,
Some issues:
export async function send_click(event, $w) {
let count = $w("#dataset1").getTotalCount();
let results = await $w("#dataset1").getItems(0, count);
let items = results.items;
for(var i = 0; i < count; i++) {
const res = await wixData.insert("SurveysSent", items[i]);
}
}
I hope this helps,
Yisrael
Shan
June 12, 2018, 6:39am
3
Thank you so much Yisrael. Sorry for bothering you
Javascript is such a vast subject, Its very difficult for someone like me with no computer programming background to find solutions to all my questions alone.
Really really appreciate your help here.
Have a good day
Hey shan,
Glad I could help. Keep in mind that we can’t always provide code solutions - but we’re here to provide guidance and direction. Keep up the good work.
Yisrael