I’m trying to build a “Notion updated DB item” polling solution. For that I save all DB records in a file, and after some period of time I read it and compare with actual data.
So I have two JSONs, I can match them by record IDs. All I need is to compare them, and in case of difference in any property, this record is considered as altered and triggers some action.
I managed to compare them by a SINGLE property (let’s say, Status). But I can’t figure out how to iterate over ALL properties while doing the stuff.
This is what I do for the SINGLE property:
- Add an “altered” boolean to the arcived data, false by default
- Change Status name of the arhived data to something else like Status_n8n
- Add these two columns to the actual data by merging it with the archived one
- Run the Function Item to check actual status against the archived one, and save true of false into the “altered” field
- Run some action on all the records which are “altered”
For comparing by a single prop, I don’t need the boolean column but it might be handy when comparing by all properties. If in some iteration I notice the difference, I can change the prop from false to true and that’s it for this record.
To iterate over ALL properties, I extract the schema from the Notion DB. Then I start the Split in batch, one by one, and try using it in renaming all the columns. But when I connect this structure to the previous solution, some wierd stuff appears like Property and Property_n8n are overlapping. And the whole loops breaks after the first run.
I guess my task is pretty common and all about comparing two JSON structures in terms of records. Would be grateful to any clue,