fix: Nested objects are encoded incorrectly for MongoDB (#8209)
BREAKING CHANGE: Nested objects are now properly stored in the database using JSON serialization; previously, due to a bug only top-level objects were serialized, but nested objects were saved as raw JSON; for example, a nested `Date` object was saved as a JSON object like `{ "__type": "Date", "iso": "2020-01-01T00:00:00.000Z" }` instead of its serialized representation `2020-01-01T00:00:00.000Z` (#8209)
This commit is contained in:
@@ -1014,6 +1014,9 @@ function mapValues(object, iterator) {
|
||||
const result = {};
|
||||
Object.keys(object).forEach(key => {
|
||||
result[key] = iterator(object[key]);
|
||||
if (result[key] && JSON.stringify(result[key]).includes(`"__type"`)) {
|
||||
result[key] = mapValues(object[key], iterator);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user