You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When dealing with optional fields, adminjs-mongoose doesn't unset removed data.
Here's an example. I'm using io-ts to validate. Suppose I have the following codec:
export const ArticleCodec = t.intersection([
uuid: t.string,
title: t.string,
t.partial({
numberOfLike: NumberFromString, // This is because data is passed as a string
avgRating: NumberFromString,
}),
]);
export type ArticleType = t.TypeOf<typeof ArticleCodec>;
I've been able to get around this problem by deleting the original document e removing all empty strings from the request payload but... I wonder if it could be possible to unset the optional values during the update.
The text was updated successfully, but these errors were encountered:
When dealing with optional fields,
adminjs-mongoose
doesn'tunset
removed data.Here's an example. I'm using io-ts to validate. Suppose I have the following codec:
I also have the following mongoose schema:
Lastly, I have the following resource:
Suppose I create an article and erroneously set
numberOfLike
instead ofavgRating
. I have the following document in MongoDB:When I edit the entity, the request I receive has the following payload:
This data is then passed to the update function which sets all data not un-setting
numberOfLike
.Mongoose, also, converts the empty string to the number 0. So, the resulting document is the following:
While I would expect this document:
I've been able to get around this problem by deleting the original document e removing all empty strings from the request payload but... I wonder if it could be possible to
unset
the optional values during the update.The text was updated successfully, but these errors were encountered: