Send inserted count to Discord

I have a workflow that ends with an Insert into a Postgres table. This works 100%. Now, I would like to send the inserted count to Discord.

If I simply connect the Discord node to the Postgres node, it executes a Discord message for every inserted record.

As an interim solution, I have inserted a Function node in between the Postgres and Discord node, with the following code:

return [
  {
    json: {
      count: $items().length
    }
  }
]

Is this the best approach?

1 Like

Yes, that is exactly the right thing to do right now.