mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
feat: pagination in nav
This commit is contained in:
parent
71fc86b9a6
commit
8289558d94
8 changed files with 84 additions and 46 deletions
|
|
@ -91,19 +91,17 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
// getConvos: async () => await Conversation.find({}).sort({ createdAt: -1 }).exec(),
|
||||
getConvos: async (pageNumber = 1, pageSize = 12) => {
|
||||
getConvosByPage: async (pageNumber = 1, pageSize = 12) => {
|
||||
try {
|
||||
const skip = (pageNumber - 1) * pageSize;
|
||||
// const limit = pageNumber * pageSize;
|
||||
|
||||
const conversations = await Conversation.find({})
|
||||
const totalConvos = await Conversation.countDocuments();
|
||||
const totalPages = Math.ceil(totalConvos / pageSize);
|
||||
const convos = await Conversation.find()
|
||||
.sort({ createdAt: -1 })
|
||||
.skip(skip)
|
||||
// .limit(limit)
|
||||
.skip((pageNumber - 1) * pageSize)
|
||||
.limit(pageSize)
|
||||
.exec();
|
||||
|
||||
return conversations;
|
||||
return { conversations: convos, pages: totalPages, pageNumber, pageSize };
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return { message: 'Error getting conversations' };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue