Added get polls route

This commit is contained in:
Manik Maity
2024-11-13 10:59:04 +05:30
parent d37af8667a
commit e007f18bb5
5 changed files with 108 additions and 4 deletions

View File

@@ -61,3 +61,24 @@ export async function updatePollVoteCount(pollId, optionId) {
throw err;
}
}
export async function findPolls(page, limit) {
try{
const skip = (page - 1) * limit;
const polls = await PollModel.find().skip(skip).limit(limit).populate("creatorId");
return polls;
}
catch(err){
throw err;
}
}
export async function getAllPollsCount(){
try{
const count = await PollModel.find().countDocuments();
return count;
}
catch(err){
throw err;
}
}