Commit 5bc65589 authored by duanjinfei's avatar duanjinfei

filter categroy is_show true

parent 2bd6be0a
......@@ -14,7 +14,7 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
while (true) {
const { data, error } = await supabase
.from(table)
.select('id,name,icon,description,points,category_id,link,images,appPlatforms,caption,is_forward,is_show,recommend') // 可以根据需要调整字段
.select('id,name,icon,description,points,category_id,link,images,appPlatforms,caption,is_forward,is_show,recommend,category(is_show)') // 可以根据需要调整字段
.gt('is_show', 0)
.gt('recommend', 0)
// .eq('is_show', 1)
......@@ -27,9 +27,13 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
console.error(`Error fetching data from ${table}:`, error);
throw error;
}
if (data && data.length > 0) {
allData = allData.concat(data); // 合并当前页数据
let newdata = data.filter((data) => {
if (data.category && data.category.is_show) {
return data.category.is_show == true;
}
});
if (newdata && newdata.length > 0) {
allData = allData.concat(newdata); // 合并当前页数据
offset += pageSize; // 移动到下一页
} else {
break; // 如果没有更多数据,则退出循环
......
......@@ -14,7 +14,7 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
while (true) {
const { data, error } = await supabase
.from(table)
.select('id,name,icon,description,points,category_id,link,images,appPlatforms,caption,is_forward,is_show') // 可以根据需要调整字段
.select('id,name,icon,description,points,category_id,link,images,appPlatforms,caption,is_forward,is_show,category(is_show)') // 可以根据需要调整字段
.gt('is_show', 0)
// .eq('is_show', 1)
.eq("category.is_show", true)
......@@ -26,8 +26,14 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
throw error;
}
if (data && data.length > 0) {
allData = allData.concat(data); // 合并当前页数据
let newdata = data.filter((data) => {
if (data.category && data.category.is_show) {
return data.category.is_show == true;
}
});
if (newdata && newdata.length > 0) {
allData = allData.concat(newdata); // 合并当前页数据
offset += pageSize; // 移动到下一页
} else {
break; // 如果没有更多数据,则退出循环
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment