Я хочу удалить резюме из списка резюме в моей схеме.
Я использую mon goose (5.9.7) и express js.
Схема
const ResumeSchema = new Schema({
user: {
type: Schema.Types.ObjectId,
ref: "User"
},
fileLink: { type: String, required: true },
fileName: { type: String, required: true },
description: { type: String, required: true }
});
module.exports = Resume = mongoose.model("Resume", ResumeSchema);
У меня есть маршрут для получения всех резюме.
Я также создаю ссылку на резюме в своей ProfileSchema.
Схема профиля
const ProfileSchema = new Schema({
user: {
type: Schema.Types.ObjectId,
ref: "User"
},
resumes: [
{
type: Schema.Types.ObjectId,
ref: "Resume"
}
],
name: {
type: String,
required: true
},
});
module.exports = Profile = mongoose.model("Profile", ProfileSchema);
Я не знаю, как добиться удаления. Я не мог заставить работать обновление или вытащить, поскольку все они, кажется, работают для массива внутри схем объекта.