Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider accepting model types as explicit parameters #20

Open
kmahar opened this issue Jan 11, 2023 · 0 comments
Open

Consider accepting model types as explicit parameters #20

kmahar opened this issue Jan 11, 2023 · 0 comments

Comments

@kmahar
Copy link

kmahar commented Jan 11, 2023

Some feedback based on the examples in the pitch for the SSWG incubation process: for the API methods that allow returning a model object, it seems worth considering accepting the model type as an explicit parameter, for example something like:

let result = try await session.query("select * from table ...", withModelType: Model.self)

While the type annotations get the job done, I think the explicit parameter is more discoverable for users, and seems more consistent with other Swift APIs. Most notably perhaps JSONDecoder:

let result = try JSONEncoder().decode(Model.self, from: myData)

But there are various other examples of this around the ecosystem too, e.g. ByteBuffer.getInteger or EventLoop.makePromise.

We've got some similar API methods in the MongoDB driver and we went with explicit type parameters for this reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant