Strapi dynamic content relationships

System Information
  • 4.8.2:

What would the best method be to create the following functionality in strapi?

I have 2 content-types

  • Product
    • id
    • customJSON
  • Inventory
    • id
    • title

I would like to set it up so that whenever an Inventory location is added, edited or deleted for the Inventory content-type in the strapi back-end, that strapi checks the customJSON field (array of objects with id and title) for each and every product in the database for a corresponding entry.

If an inventory was created, it should append it to the array if no corresponding entry exists

If inventory was edited, the title should be updated (or appended to the array if no corresponding entry exists).

If an inventory was deleted, the corresponding item should be deleted.