I think I missed a property:
import wixData from 'wix-data'
export const copyRowsCount = async () => {
let query = await wixData.query('Source').limit(1000).find()
let allItems = query.items //this was the error.
let results = []
allItems.forEach((item) => {
for (let i = 0; i < item.count; i++) {
results.push({ title: item.title, isbn: item.isbn })
}
}) //This is going to select the items to be added.
await wixData.bulkInsert('Destination', results)
}
I was reading the WIX Data API today and remembered there was one more thing wrong with the code, the .insert() method.
I changed to the correct one but there is a limit of 1000 items now. Let me know if you need the code to be more than 1000 items.