It’s my first time using mongo and I’m facing a problem now I want to delete a certain element in the collection at a specific date.
I tried to use expirationDate but it deleted the whole collection not just the element
Here is my schema and the element that I want to delete from the schedule.
{
userId: {
$ref: ‘User’,
type: Schema.Types.ObjectId,
required: true,
},
languages: {
type: [String],
enum: [‘JS’, ‘PHP’, ‘C++’, ‘C#’, ‘RUBY’, ‘PYTHON’, ‘JAVA’, ‘C’, ‘GO’],
required: true,
},
specialization: {
type: String,
enum: [‘FRONTEND’, ‘BACKEND’, ‘DEVOPS’, ‘SECURITY’, ‘DATA STRUCTURE’, ‘FULL STACK’],
required: true,
},
interviews: {
type: [
{
intervieweeId: {
$ref: ‘Interviewee’,
type: String,
required: true,
},
date: {
type: Date,
required: true,
},
time: {
type: Number,
required: true,
},
language: {
type: String,
enum: [‘JS’, ‘PHP’, ‘C++’, ‘C#’, ‘RUBY’, ‘PYTHON’, ‘JAVA’, ‘C’, ‘GO’],
required: true,
},
specialization: {
type: String,
enum: [‘FRONTEND’, ‘BACKEND’, ‘DEVOPS’, ‘SECURITY’, ‘DATA STRUCTURE’, ‘FULL STACK’],
required: true,
},
questionCategory: {
type: String,
required: true,
enum: [‘Technical’, ‘Analytical’, ‘Algorithms’, ‘System Design’],
},
},
],
required: false,
},
schedule: {
type: [
{
date: {
type: Date,
required: true,
},
time: {
type: Array,
required: true,
},
},
],
required: false,
},
}
Schedule it an array of objects and I need to delete a specific object in the schedule array.