@vince Actually, I didn’t update anything since more than a year, and it always worked.
Here is the model (simplified) :
module.exports = (mongoose, Mongoose) => {
const schema = Mongoose.Schema(
{
email: String,
telephone: String,
firstname: String,
lastname: String,
githubMember: {
type: Mongoose.Schema.Types.ObjectId,
ref: "GithubMembers",
},
sessions: [
{ type: Mongoose.Schema.Types.ObjectId, ref: "SessionsApollo" },
],
leads: [{ type: Mongoose.Schema.Types.ObjectId, ref: "Leads" }], // !!!!!!
infos: String,
commentsArr: [
{ type: Mongoose.Schema.Types.ObjectId, ref: "CommentsStudents" },
],
mailinglist: Boolean,
documents: [{ type: Mongoose.Schema.Types.ObjectId, ref: "Documents" }],
status: {
type: String,
default: "prework",
},
isFlagged: {
type: Boolean,
default: false,
},
linkedIn: String,
exams: [
{
type: Mongoose.Schema.Types.ObjectId,
ref: "SessionsApollo",
},
],
createdAt: {
type: Date,
default: Date.now,
},
updatedAt: {
type: Date,
default: Date.now,
},
},
{
timestamps: false,
}
);
return mongoose.model("Students", schema, "students");
};
And object for “valeri” :
{
"_id": {
"$oid": "641083c3f447ae00141a63ac"
},
"sessions": [
{
"$oid": "62b2f80705ed090018f35200"
}
],
"leads": [
{
"$oid": "63d79e7e1ab49c0016ec3418"
},
{
"$oid": "64de2128c201380014f68360"
}
],
"commentsArr": [],
"documents": [
{
"$oid": "641083ecf447ae00141a63b0"
}
],
"status": "training",
"isFlagged": false,
"exams": [],
"email": "xxxxx@yahoo.fr",
"telephone": "+33xxxxxxxxx",
"firstname": "Valerie",
"lastname": "XXXX",
"mailinglist": true,
"createdAt": {
"$date": "2023-03-14T14:25:07.187Z"
},
"updatedAt": {
"$date": "2023-03-14T14:25:07.187Z"
},
"__v": 0,
"githubMember": [
{
"$oid": "641effa7f79a140014a47a3b"
}
],
}