Feat: change Create Api to a less verbose one, utilizing funcs - #39
Merged
Conversation
1- Define {model}CreateBuilder that houses a pointer to the createBuilder generic, define Set{Field}() per field on the creates, to avoid writing package.Field.Set() each time, now it's just a chained func after declaring the Create()
2-Keep the delegate's Create(assignments ...FieldAssignment) variadic to ensure backward compatibility with existing single-creation call sites, at least for now
3- change CreateMany/AndReturn() to accept builders, easy for grouping creates to be in batches or constructing slices with data by looping
4- Fix Sqlite dialect's SupportBulkInsert() to return true as,, what do u know, it supports bulk inserts.
5- Define CreateBuilder Alias on model packages for ease of use on constructing slices for createMany/AndReturn()
6- Adapt test files to the new api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1- Define {model}CreateBuilder that houses a pointer to the createBuilder generic, define Set{Field}() per field on the creates, to avoid writing package.Field.Set() each time, now it's just a chained func after declaring the Create()
2-Keep the delegate's Create(assignments ...FieldAssignment) variadic to ensure backward compatibility with existing single-creation call sites, at least for now
3- change CreateMany/AndReturn() to accept builders, easy for grouping creates to be in batches or constructing slices with data by looping
4- Fix Sqlite dialect's SupportBulkInsert() to return true as,, what do u know, it supports bulk inserts.
5- Define CreateBuilder Alias on model packages for ease of use on constructing slices for createMany/AndReturn()
6- Adapt test files to the new api