I have a page with a menu on it. I created an array of all the repeaters on the page and am looping through to populate the different sections. I am trying to filter the correct items from the dataset into different sections of the menus using multiple repeaters. using query is working but the loop is making too many database requests and the page is loading very slowly. I think if I use setFilter instead of query the page will load faster but I am getting errors.
An error occurred in one of datasetReady callbacks TypeError: _wixData2.default.filter(...).eq(...).find is not a function
Can anyone help me filter this? You can see the filter code commented out that is not working.
here is the page: https://www.dogtoothbar.com/lunch-menu
// For full API documentation, including code examples, visit https://wix.to/94BuAAs
import wixData from "wix-data";
import { menuAdd, menuPrice } from 'public/menu.js'
import wixWindow from 'wix-window';
const containerData = [{
section: 'lunchAppCol1',
repeater: '#repeater1',
title: '#text40',
description: '#text41',
price: '#text42',
add: '#text176'
},
{
section: 'lunchFlatbreadCol1',
repeater: '#repeater3',
title: '#text47',
description: '#text48',
price: '#text49',
add: '#text177'
},
{
section: 'lunchSoupCol1',
repeater: '#repeater5',
title: '#text54',
description: '#text55',
price: '#text56',
add: '#text178'
},
{
section: 'lunchSaladCol1',
repeater: '#repeater7',
title: '#text62',
description: '#text63',
price: '#text64',
add: '#text179'
},
{
section: 'lunchBarCol1',
repeater: '#repeater9',
title: '#text69',
description: '#text70',
price: '#text71',
add: '#text180'
},
{
section: 'lunchburgers',
repeater: '#repeater10',
title: '#text72',
description: '#text73',
price: '#text74',
add: '#text181'
},
{
section: 'lunchSpecial',
repeater: '#repeater11',
title: '#text76',
description: '#text77',
price: '#text78',
add: '#text182'
}
];
$w.onReady(() => {
Object.values(containerData).forEach(item => {
wixData.query("MenuItems")
.eq(item.section, true)
.ascending("lunchOrder")
.find()
.then((results) => {
$w(item.repeater).data = results.items;
}).catch((err) => {
console.log(err);
});
// $w("#dataset1").onReady(() => {
// Object.values(containerData).forEach(item => {
// $w("#dataset1").setFilter(wixData.filter()
// .eq(item.section, true)
// .find()
// .then((results) => {
// console.log(results.items);
// let filteredData = results.items;
// $w(item.repeater).data = filteredData;
// $w(item.repeater).show();
// }).catch((err) => {
// console.log(err);
// })
// );
$w(item.repeater).onItemReady(($w, dataItem, index) => {
$w(item.title).text = dataItem["title"];
$w(item.description).text = dataItem["description"];
menuAdd($w(item.add), dataItem["add1"], dataItem["add2"]);
menuPrice($w(item.price), dataItem["price"]);
});
if(wixWindow.formFactor === "Mobile") {
$w('#columnStrip8').background.src = 'https://static.wixstatic.com/media/933710_5859ff6437a348798dd6f1c5f6dc3380~mv2.jpg';
}
});
});
// });