Help with bulk insert

I am having problems getting this bulk insert to work!! Here is what I am trying to do:

  1. A form where people can log in and there ranks to a list (List of 75 ish items where they pick top 25)
  2. Be able to log in and view and edit here list easily
  3. 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

Hey Did you get the value from the national champion query?
if yes can you screenshot the toInsertArray?

just wanted to update, I have it to where I am getting an actual array not just a search object:

export function ythHmsGenerate() {
wixData.query("IndividualJudgesPlacings")
	.eq("ythHms", true)
	.eq("owner", user.id)
	.limit(100)
	.find()
	.then((results) => {
		console.log(results)
		let items = results.items;
		let titles = items.map(item => item.title);
		console.log("here are titles" + titles)
		wixData.query("NationalChampionshipRankings")
			.not(wixData.query("NationalChampionshipRankings")
			.hasSome("title", titles)
				)
			.eq("youthHms", true)
			.limit(100)
			.find()
			.then((results) => {
				console.log(results)
				let items2 = results.items
				let needsToBeInserted = items2.map(item => [item.title, item.youthHms, item.youthEq, item.youthSms])
				console.log(needsToBeInserted)
				//end of loop
				//wixData.bulkInsert("IndividualJudgesPlacings", needsToBeInserted)
				//console.log("done maybe");
				//console.log ("Bulk Insert Results" + results)
				//$w("#repeater1").expand();

					//.catch((err) => {
					//let errorMsg = err;
				});
		})
}

here is what I am getting from browser console:


but now:

//wixData.bulkInsert("IndividualJudgesPlacings", needsToBeInserted)

does not do anything (I know currently it has // to stop it but even without those it does nothing, I am just trying to play with the array at the moment). Any ideas?

Solved in https://www.wix.com/corvid/forum/community-discussion/using-wixdata-bulkinsert-with-an-array