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
❗ Is your feature request related to a problem? Please describe.
We use started using microdiff as a pre-step before doing db updates. When working with MongoDB, then use the ObjectId data type which is exported by the bson package to keep track of documents (records) and references between data.
It can be compared in JS using the toString() (or casting it to string).
However, currently microdiff compares it as an object and because the object has no properties (only methods), it can not identify the change.
✅ Describe the solution you'd like
In order for us to solve this issue and have microdiff detect changes to properties that are ObjectId, we needed to duplicate the function to our code base and extend the rich types object with the ObjectId: true property to have it trigger the "rich type" check and be evaluated as two strings being compared with each other.
↗️ Describe alternatives you've considered
I would recommend adding a property to the third argument of the function where cyclesFix can be passed in. This would be an object of extended rich types which then also need to be checked while calling the diff function.
➕ Additional context
Other data types in JS which have a compatible (to String) method of comparing them can be added to this and thus we can still use the microdiff library without having to duplicate the functionality.
The text was updated successfully, but these errors were encountered:
joshua-ds
changed the title
➕ Feature - [SHORT DESCRIPTION]
➕ Feature - Extend the diff function with rich types not included in the base JS language.
Apr 15, 2024
joshua-ds
changed the title
➕ Feature - Extend the diff function with rich types not included in the base JS language.
Extend the diff function with rich types not included in the base JS language.
Apr 15, 2024
❗ Is your feature request related to a problem? Please describe.
We use started using
microdiff
as a pre-step before doing db updates. When working with MongoDB, then use theObjectId
data type which is exported by the bson package to keep track of documents (records) and references between data.It can be compared in JS using the toString() (or casting it to string).
However, currently microdiff compares it as an object and because the object has no properties (only methods), it can not identify the change.
✅ Describe the solution you'd like
In order for us to solve this issue and have microdiff detect changes to properties that are ObjectId, we needed to duplicate the function to our code base and extend the rich types object with the
ObjectId: true
property to have it trigger the "rich type" check and be evaluated as two strings being compared with each other.I would recommend adding a property to the third argument of the function where
cyclesFix
can be passed in. This would be an object of extended rich types which then also need to be checked while calling thediff
function.➕ Additional context
Other data types in JS which have a compatible (to String) method of comparing them can be added to this and thus we can still use the microdiff library without having to duplicate the functionality.
The text was updated successfully, but these errors were encountered: