Hi everyone i have a collection (almost 350 rows), and when i select my checkboxes to display my collection in a table it just allows me to select some datas. All my data do not appear in the multiple checkboxes and when i check the console log it says that the limitNumber of my collection is 50.
I would like someone to help me fix this please
Hi k’v NG,
this thread might help you
https://www.wix.com/corvid/forum/community-discussion/getting-data-query-over-1000-limit
use the .limit() function
kristof.
As I mentioned in my first comment, s ee the limit() API .
You might also want to consider displaying only 50 at a time, and then paging using the Pagination API .
Please don’t open multiple posts with the same question.
Yisrael excuse me for creating multiple posts please.
Thank you all for your answers i tried to do it with limit API but it still doesnt work.
Here is the code:
import wixData from ‘wix-data’;
import {local} from ‘wix-storage’;
wixData.query(“stores”)
.limit(1000)
.find()
.then( (results) => {
if(results.items.length > 0) {
let items = results.items;
let firstItem = items[0];
let totalCount = results.totalCount;
let pageSize = results.pageSize;
let currentPage = results.currentPage;
let totalPages = results.totalPages;
let hasNext = results.hasNext();
let hasPrev = results.hasPrev();
let length = results.length;
let query = results.query;
} else {
// handle case where no matching items found
}
} )
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
let columns = [{
“id”: “col1”,
“dataPath”: “firm”,
“label”: “Firm”,
“type”: “string”
}]
$w.onReady(function () {
init();
});
async function init() {
let data = (await wixData.query(“stores”).find()).items;
buildCat();
// console.log(data);
let firmOptions = noDublicate(data.map(el => el.firm));
let proOptions = noDublicate(data.map(el => el.product));
$w(‘#checkGFirm’).options = buildOptions(firmOptions);
// $w(‘#checkGPro’).options = buildOptions(proOptions);
$w(‘#btnSearch’).onClick(filter);
$w(‘#btnClear’).onClick(clear);
$w(‘#repeater1’).onItemReady(($item, itemData, i)=>{
$item(‘#textCat’).text = itemData.catName;
$item(‘#checkGProd’).options = buildOptions(itemData.proOptions);
});
$w(‘#boxFirm’).onClick(()=>toggleCollapse(“checkGFirm”));
$w(‘#boxPro’).onClick(()=>toggleCollapse(“repeater1”));
// restrict 6 products
let maxPro = 6;
let lastCats = {};
$w(‘#checkGProd’).onChange(el=>{
let {prods, cats} = getProd();
if(prods.length > 6) {
$w('#repeater1').forEachItem(($item, itemData, i) =>{
let cat = itemData.catName;
let lastProds = lastCats[cat];
$item('#checkGProd').value = lastProds;
});
} else {
lastCats = cats;
}
});
}
async function filter() {
$w(‘#textLoading’).show();
let {prods} = getProd();
let isValid = validation(prods);
if (isValid !== “true”) {
$w(‘#textLoading’).text = isValid;
$w(‘#textLoading’).show()
return;
}
let checkGFirm = $w(‘#checkGFirm’).value;
let checkGPro = prods; //$w(‘#checkGPro’).value;
checkGPro.forEach((el, i) => {
columns.push({
id: “col” + (i + 2),
“dataPath”: el,
“label”: el,
“type”: “string”
});
});
$w(‘#table’).columns = columns;
// build columns for table
let rows = await getstores(checkGFirm, checkGPro)
$w(‘#table’).rows = rows;
$w(‘#table’).show();
$w(‘#textLoading’).hide();
}
function clear() {
$w(‘#checkGFirm’).selectedIndices = [];
// $w(‘#checkGPro’).selectedIndices = [];
$w(‘#checkGProd’).selectedIndices = [];
filter();
}
function validation(prods) {
if ($w(‘#checkGFirm’).selectedIndices.length === 0) {
return “Select at least one firm”;
}
if (prods < 1) {
return “Select at least two product”;
}
columns = [{
“id”: “col1”,
“dataPath”: “firm”,
“label”: “Firm”,
“type”: “string”
}]
return “true”;
}
async function getstores(firms, products) {
try {
let res = await wixData.query(“stores”)
.hasSome(“product”, products)
.hasSome(“firm”, firms)
.find()
console.log("data found : ", res, res.length);
// build rows
let data = res.items;
let uniqueRows = [];
data.forEach(row => {
let firmsUni = uniqueRows.map(el => el.firm);
let pos = firmsUni.indexOf(row.firm);
if (pos === -1) {
uniqueRows.push({
firm: row.firm
});
pos = firmsUni.length
}
columns.forEach(col => {
let colKey = col.dataPath;
if (colKey === "firm") return;
if (colKey === row.product) {
uniqueRows[pos][colKey] = row.price;
}
});
});
let rows = [];
@yisrael please help me, can you tell me how to integrate the limit() API to my code ?
@volkaertskristof thank you for your answer but it did not work can you please tell me how to integrate it to my code ?
Thank you yisrael it finally worked. Muchas