Index events from multiple contracts in one table

I have a contract factory that instantiates other contracts. I want to be able to watch events for each of the created contract instances and subsequently create a new object every time an event is triggered. Effectively, indexing specific data from the contracts in an organized manner. In terms of steps it would look something like this:

  1. Contracy factory instantiates a new contract.
  2. Run the watchContractEvent cloud function for 2 events in the created contract.
  3. afterSave of a new event, a new object is created and saved to the database.

Below is my cloud function code for step 2:

Moralis.Cloud.define("watchEvents", async (request) => {
  console.log(request.params.address)
  let options1 = {
        chainId: "0x4",
        address: request.params.address,
        topic:
          "EditionCreated(uint256, address, uint256, uint32, uint32, uint32, uint32, string)",
        sync_historical: false,
        abi: {
          anonymous: false,
          inputs: [
            {
              indexed: true,
              internalType: "uint256",
              name: "editionId",
              type: "uint256",
            },
            {
              indexed: true,
              internalType: "address",
              name: "artistAddress",
              type: "address",
            },
            {
              indexed: true,
              internalType: "uint256",
              name: "price",
              type: "uint256",
            },
            {
              indexed: false,
              internalType: "uint32",
              name: "quantity",
              type: "uint32",
            },
            {
              indexed: false,
              internalType: "uint32",
              name: "royaltyBPS",
              type: "uint32",
            },
            {
              indexed: false,
              internalType: "uint32",
              name: "startTime",
              type: "uint32",
            },
            {
              indexed: false,
              internalType: "uint32",
              name: "endTime",
              type: "uint32",
            },
            {
              indexed: false,
              internalType: "string",
              name: "ipfsHash",
              type: "string",
            },
          ],
          name: "NewEditionCreated",
          type: "event",
        },
        tableName: "EditionCreated",
      };

      let options2 = {
        chainId: "0x4",
        address: request.params.address,
        topic: "EditionPurchased(uint256, uint256, uint32, address)",
        sync_historical: false,
        abi: {
          anonymous: false,
          inputs: [
            {
              indexed: true,
              internalType: "editionId",
              name: "editionId",
              type: "uint256",
            },
            {
              indexed: true,
              internalType: "tokenId",
              name: "artistAddress",
              type: "uint256",
            },
            {
              indexed: true,
              internalType: "numSold",
              name: "price",
              type: "uint256",
            },
            {
              indexed: false,
              internalType: "address",
              name: "buyer",
              type: "address",
            },
          ],
          name: "NewEditionPurchases",
          type: "event",
        },
        tableName: "EditionPurchased",
      };

      Moralis.Cloud.run("watchContractEvent", options1, { useMasterKey: true });
      Moralis.Cloud.run("watchContractEvent", options2, { useMasterKey: true });
})

This works fine for the first instantiated contract, however after that Moralis gives me an error sayng ‘tableName should be unique’. See screenshot below.

Is it possible to achieve what I am attempting to do with watchContractEvent, using the same tableName across multiple contracts? Creating a new table for each new instantiated contract would clutter the database.

If not is there an viable alternatives?

for now I think that you have to use different table names for every event.
after that you can run a job every x minute if you want to move the events to a single table from all those tables.

How would I trigger a cloud function for each new event if the tables all have different names?

You could use a job that gets the list of tables from another table and processes new events every x minutes.