Closed thecodingwizard closed 3 years ago
I see what this fix achieves, but myself I only had strings / numbers in mind for the value of matchFields. What's the reason you went with an object?
In my application I had records of "programming problems" that could be filtered by tags (ie. Dynamic Programming, Shortest Path, Graphs, etc). Each record would contain an array of tags. (WIP example: https://usaco.guide/problems/)
As for objects, my use case was a bit more specific -- for each problem, I would store an array of "pages" on the website that each problem appeared in. Each page would be stored as an object with two properties: the slug and the title of the page.
(This is my first time using Algolia, so perhaps there's a better way to design this?)
matchFields is more meant to check whether a record has changed, so something like a date modified, or a hash of the content on that record. If you only add the slug & tags, it will not update when the content updates
Apologies if I'm misunderstanding, but if I want the record to update when the tags have changed, how should I achieve this? (I don't have a last modified timestamp, and it seems overly complicated to hash the object and add a hash field to the record solely to check for changes...)
To clarify, I had previously included tags in the matchFields array, but that was being marked as a change every time, even if the contents of the tags array didn't change.
if the record indeed basically only contains those records, comparing the whole value is a reasonable option. Let's go with this
Previously, when using
enablePartialUpdates
withmatchFields
, fields were compared using the===
operator. This meant that objects and arrays would be flagged to be updated even if the contents of the objects and arrays were unchanged. This PR usesdeep-equal
to detect changes, so objects and arrays that have the same value would not trigger an unnecessary update.