feat: add soft delete for classes with cascade to sessions and linked records
This commit is contained in:
@@ -51,7 +51,16 @@ const pendingStudentSchema = new mongoose.Schema({
|
||||
paymentReference: { type: String, trim: true },
|
||||
adminNotes: { type: String, trim: true, maxlength: 2000 },
|
||||
reviewedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
|
||||
reviewedAt: { type: Date }
|
||||
reviewedAt: { type: Date },
|
||||
isDeleted: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
index: true
|
||||
},
|
||||
deletedAt: {
|
||||
type: Date,
|
||||
default: null
|
||||
}
|
||||
}, {
|
||||
timestamps: true
|
||||
});
|
||||
|
||||
@@ -256,6 +256,11 @@ const getAllPendingStudents = async (query = {}) => {
|
||||
const skip = (page - 1) * limit;
|
||||
|
||||
const filter = {};
|
||||
if (query.trash === 'true' || query.isDeleted === 'true') {
|
||||
filter.isDeleted = true;
|
||||
} else {
|
||||
filter.isDeleted = { $ne: true };
|
||||
}
|
||||
if (query.status) filter.status = query.status;
|
||||
if (query.type) filter.type = query.type;
|
||||
if (query.classId) filter.class = query.classId;
|
||||
|
||||
Reference in New Issue
Block a user