|
@@ -22,6 +22,25 @@ class StudentService extends CrudService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ async findbedroom({ batchid }) {
|
|
|
+ const students = await this.model.find({ batchid });
|
|
|
+ const bedroomList = new Set();
|
|
|
+ for (const student of students) {
|
|
|
+ bedroomList.add(student.bedroom);
|
|
|
+ }
|
|
|
+ const result = [];
|
|
|
+ let studentList = [];
|
|
|
+ for (const bedroom of bedroomList) {
|
|
|
+ const newstudents = await this.model.find({ bedroom });
|
|
|
+ for (const newstudent of newstudents) {
|
|
|
+ studentList.push(newstudent.name);
|
|
|
+ }
|
|
|
+ result.push({ bedroom, studentList });
|
|
|
+ studentList = [];
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
module.exports = StudentService;
|