Feature(s) impacted
Updating a field in a “child” collection
Failure Logs
None
Context
- Agent technology: NodeJS (Express)
- Agent (forest package) name & version: forest-express-mongoose (9.3.17)
- Database type: MongoDB, Mongoose
Message
Hello!
I’m trying to update a field that contains an empty value. (example : john@doe.com
→ null | ""
)
Here is the data structure:
const StoreSchema = new mongoose.Schema(
{
name: { type: String, required: true },
websites: { type: [WebsiteSchema], required: false, default: [] },
}
)
export const WebsiteSchema = new mongoose.Schema(
{
name: { type: String, required: true },
url: { type: String, required: true },
color: { type: String, required: false },
email: { type: String, required: false },
},
{ _id: false }
)
When I change the “email” field of one of my websites to an empty value, forest tells me “websites successfully updated.”, but as soon as I refresh the page, the value is back to what it was before…
I created a middleware in my API to understand the body that is sent when I set the “email” field to empty:
{
data: {
attributes: {
name: 'test_website',
url: 'https://my_url.com',
color: '#FFF'
}
}
}
Concretely, as I passed email to ""
, it is not sent, and therefore not modified.
From what I remember, we didn’t have this problem before. Has anything changed? And if not, what would the workaround be?
Thank you very much!