product pagination

This commit is contained in:
Sibunnayak 2024-11-26 16:56:57 +05:30
parent 4972241bf7
commit 1cbdaca757

View File

@ -508,8 +508,8 @@ export const getAllProductAdmin = async (req, res) => {
export const getAllProductUser = async (req, res) => {
try {
// Set default values for pagination
const PAGE_SIZE = parseInt(req.query?.show || "10");
const page = parseInt(req.query?.page || "1") - 1;
// const PAGE_SIZE = parseInt(req.query?.show || "10");
// const page = parseInt(req.query?.page || "1") - 1;
let filter = {};
// Filter by category name
@ -553,8 +553,8 @@ export const getAllProductUser = async (req, res) => {
path: "category addedBy brand",
select: "categoryName name brandName",
})
.limit(PAGE_SIZE)
.skip(PAGE_SIZE * page)
// .limit(PAGE_SIZE)
// .skip(PAGE_SIZE * page)
.sort({ createdAt: -1 })
.exec();