product pagination
This commit is contained in:
parent
4972241bf7
commit
1cbdaca757
@ -508,8 +508,8 @@ export const getAllProductAdmin = async (req, res) => {
|
|||||||
export const getAllProductUser = async (req, res) => {
|
export const getAllProductUser = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// Set default values for pagination
|
// Set default values for pagination
|
||||||
const PAGE_SIZE = parseInt(req.query?.show || "10");
|
// const PAGE_SIZE = parseInt(req.query?.show || "10");
|
||||||
const page = parseInt(req.query?.page || "1") - 1;
|
// const page = parseInt(req.query?.page || "1") - 1;
|
||||||
let filter = {};
|
let filter = {};
|
||||||
|
|
||||||
// Filter by category name
|
// Filter by category name
|
||||||
@ -553,8 +553,8 @@ export const getAllProductUser = async (req, res) => {
|
|||||||
path: "category addedBy brand",
|
path: "category addedBy brand",
|
||||||
select: "categoryName name brandName",
|
select: "categoryName name brandName",
|
||||||
})
|
})
|
||||||
.limit(PAGE_SIZE)
|
// .limit(PAGE_SIZE)
|
||||||
.skip(PAGE_SIZE * page)
|
// .skip(PAGE_SIZE * page)
|
||||||
.sort({ createdAt: -1 })
|
.sort({ createdAt: -1 })
|
||||||
.exec();
|
.exec();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user