mc738 / Freql

A record mapping library for FSharp and various data sources.
MIT License
2 stars 0 forks source link

Add support for `Operations.insert[name]Records` to code gen #19

Open mc738 opened 8 months ago

mc738 commented 8 months ago

Is your feature request related to a problem? Please describe. Add support for adding multiple records via code gen. This can take 2 forms either wrapped in a transaction or not.

This could be supported with a try naming prefix. Also this could be expanded to to single record inserts as well.

Describe the solution you'd like Add a new set code gen operations:

// For type Foo

// Current
Operations.insertFoo ctx foo

// New
Operations.insertFooRecords ctx foos // Returns string, can throw exception
Operations.tryInsertFooRecords ctx foos // Returns Result<unit, string>, wraps in transaction.

Operations.tryInsertFooRecord ctx foo // Returns Result<unit, string>, wraps in transaction.

Also possible rename Operations.insertFoo to Operations.insertFooRecord to keep a standard naming convention.

Adding Record as a suffix deals with naming readability around plurals.

For example records called series where the name can both singular and plural or cases where the plural is not simply created by adding s to the end.

Describe alternatives you've considered This can be achieve by the user reasonable easy, but this would be a nice convenience and move some potential boiler plating to generated code.

Additional context This is a nice to have so doesn't need to hold anything else up.

mc738 commented 8 months ago

I will get round to adding this at some point, there needs to be some thought around the signatures and wrapping in transactions.