How to findOne and then post the item if not found?

i have a categories collection type, and i have form (in react) that accepts categories from users.
now i want to get these categories from the user, and then see if they are already in the database.
if one (or multiple) category is not found, then i post them!

i tried to that with filter and map, but then i run into a problem of finding the ID of the categories, because these are in relation of other collection type

I think the way i would solve this is to do the following.

  1. Create a GET request to an endpoint to get the data back. Then check if the data exists or the ID exists. If it does not switch it over to make a post request to another endpoint to create it.

I’m guessing you can also do this behind the scenes in strapi itself.
Extend or create your own endpoint that gets the data, if it’s undefined then make the data itself.

1 Like

Exactly this