Implement pagination
This commit is contained in:
@@ -3,9 +3,12 @@ import PropertySearchForm from '@/components/PropertySearchForm';
|
||||
import Property from '@/models/Property';
|
||||
import connectDB from '@/config/database';
|
||||
|
||||
const PropertiesPage = async () => {
|
||||
const PropertiesPage = async ({ searchParams: { pageSize = 3, page = 1 } }) => {
|
||||
await connectDB();
|
||||
const properties = await Property.find({}).lean();
|
||||
const skip = (page - 1) * pageSize;
|
||||
|
||||
const total = await Property.countDocuments({});
|
||||
const properties = await Property.find({}).skip(skip).limit(pageSize);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user