Currently, CRUD operations in the crud module accept optional parameters via a single .Opts(...) call that takes a large struct (e.g. ReplaceObjectManyOpts). This approach has a few drawbacks:
- It forces users to construct a full struct even when only one option is needed (especially if user uses
exhaustruct linter).
- It is less discoverable.
- It makes call sites more verbose and less fluent compared to method chaining.
Proposal is to replace the .Opts(...) pattern with individual builder methods for each optional field:
req := crud.MakeReplaceObjectManyRequest("my_space").
Objects(myObjects).
Timeout(5.0).
Fields("id", "name").
StopOnError(true)
This style aligns better with common Go API design patterns and improves usability, especially for newcomers and interactive development.
Checklist
Currently, CRUD operations in the crud module accept optional parameters via a single
.Opts(...)call that takes a large struct (e.g.ReplaceObjectManyOpts). This approach has a few drawbacks:exhaustructlinter).Proposal is to replace the
.Opts(...)pattern with individual builder methods for each optional field:This style aligns better with common Go API design patterns and improves usability, especially for newcomers and interactive development.
Checklist