const getfunction = async ({ query, queryCondition, params }) => {
try {
const candidates = []
const rejectedArray = []
const droppedArray = []
let alldata = await CollectionName.aggregate(
{
$sort: sortQuery
},
])
for (var x=0; x<alldata.length; x++) {
if(alldata[x].stat != 'Rejected' && alldata[x].stat != 'Dropped') {
candidates.push(alldata[x])
}
else if(alldata[x].stat === 'Dropped') {
droppedArray.push(alldata[x])
}
else if(alldata[x].stat === 'Rejected') {
rejectedArray.push(alldata[x])
}
}
for(var y=0; y<droppedArray.length; y++) {
candidates.push(droppedArray[y])
}
for(var z=0; z<rejectedArray.length; z++) {
candidates.push(rejectedArray[z])
}
} //close try
catch (err) {
console.log(err)
}
} //close function
Top comments (0)