I am having problems getting this bulk insert to work!! Here is what I am trying to do:
- A form where people can log in and there ranks to a list (List of 75 ish items where they pick top 25)
- Be able to log in and view and edit here list easily
- Have the list sort based on there entries (1-25 first then alphabetically after that)
My thought is I have a database with the master list, people log in and go the page. When they call the generateEq function, it compares the individualrank list with the master list. It then takes anything in the master list that isn’t already in the individual rank list and inserts those items into the individual ranks list.
I have a repeater that populates and is filtered to only be the content that the logged in individual is the owner of (since they called the bulk insert function they become the owner). Now they can view and edit there list anytime.
Here is the code I have:
export function ythEqgenerate() {
$w("#dataset1").getItems(0, 100)
.then((results) => {
console.log(results)
let items = results.items;
let titles = items.map(item => item.title);
console.log(titles)
wixData.query("NationalChampionshipRankings")
.not(
wixData.query("NationalChampionshipRankings")
.hasSome("title", titles)
)
.eq("youthEq", true)
.limit(100)
.find()
.then((results) => {
console.log(results + "hasnt worked to this point yet")
let toInsertArray = [];
for (var i=0; i < results.length;
i++){
let toInsert = {
// "owner": i,
"title": results[i].title,
"ythEq": results[i].ythEa
};
toInsertArray.push(Object.assign({}, toInsert));
}//end of loop
wixData.bulkInsert("IndividualJudgesPlacings", toInsertArray)
.then((results) => {
console.log("done this time");
$w("#repeater1").expand();
})
.catch((err) => {
let errorMsg = err;
});
})
})
I am not sure where to go next