override all entries in a collection in API

hello … I need to delete all entries in a collection from time to time and insert new ones. this dynamically without the dashboard. In fact, it will be powered by a Json that I will receive from another system. Has as? Has anyone done?

You can do in several ways:

  1. Command line - create a cli command that empties the collection entries, believe you can do:
    $app->module('collections')->remove('colectionname', []);
  2. Rest Endpoint - create a REST endpoint that receives the collection name and runs above command (think that option could be dangerous, if doing that ensure you have a custom API key for it)
  3. Via a trigger action, let’s imagine that you have a singleton or other collection that when saved you want to flush some other collection, implement the proper trigger using the dropCollection method