IntentArchitect / Support

A repository dedicated to handling issues and support queries
3 stars 0 forks source link

Creating a custom command that takes a list of items #91

Closed alinsky-afk closed 5 months ago

alinsky-afk commented 5 months ago

Ask a question

Hi All,

Is it possible to create a custom command that accepts a list of items? For example I would like to mass insert records to a table and I would like pass a list as a parameter. Instead of looping through a list and making a single create request for each. I've attached a screenshot below for just an idea of what I want.

Thanks!

image

JonathanLydall commented 5 months ago

Hi @alinsky-afk,

We don't presently have a mapping configuration which could be used to describe this requirement, but you can still model the command's contract and then implement the handler code manually.

For example, if you wanted to bulk create Customers as per the following:

image

Create a DTO, with a name such as CreateCustomerDto, with the Fields you need:

image

Then create a Command with a name such as CreateCustomersCommand, add a Customers Field to it set to CreateCustomerDto and ensure you have set Is Collection for it:

image

Run the Software Factory and it will generate a stub for you, you can then just implement the logic you need in there:

image

I've also logged a feature request for us possibly adding support for this kind of use case to our modules, however, as our resources are a bit limited at the moment, I can't say when we might be able to implement it.

Please don't hesitate to let me know if you have any additional comments or questions.

alinsky-afk commented 5 months ago

Thanks @JonathanLydall this worked just fine! 🔥