I have been following this tutorial on how to get import large amounts of json via the insert() command https://support.wix.com/en/article/corvid-tutorial-importing-and-exporting-collection-data-with-code
I modified it as follows to check for existing records
export function importButton_click(event) {
//Add your code for this event here:
const items = JSON.parse($w("#textBox").value);
const collection = $w("#collectionInput").value;
let options = {
"suppressAuth": true,
"suppressHooks": true
};
$w("#textBox").value = "";
items.forEach((item) => {
//console.log("id" + item._id);
//check the collection to see if the id exists
wixData.get(collection, item._id, options)
.then((results) => {
if (results === null) {
//if its null then add it.
wixData.insert(collection, item, options)
.then((results) => {
//console.log(`Added item: ${JSON.stringify(results)}`);
})
.catch((err) => {
console.log(err);
});
}
})
.catch((errr) => {
console.log(errr);
})
});
//$w("#textBox").value = JSON.stringify(errorItems)
}
My problem is that after i get so many records in the .get starts failing with a very undescriptive error message.
Error
at i (wixCodeNamespacesAndElementorySupport.min.js:1)
at XMLHttpRequest.n.onreadystatechange (wixCodeNamespacesAndElementorySupport.min.js:1)
at XMLHttpRequest.wrapped (raven.js:375)
The CSV i am trying to add is 24576 lines long. Attached is the example JSON that was generated from the CSV.
Any tips would be greatly appreciated. This is a test case example, my actual use case will be closer to 8 million rows.