-
Notifications
You must be signed in to change notification settings - Fork 95
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
Connection.query() return type #185
Comments
It would be nice to have, but not as simple than that. For update/insert there is already an UpsertResult type defined, return would be Promise
That's for the default option value. but let me show the problem with only 2 options
another options The only choice would be to remove That would not be so interesting. Maybe another notation like in JDBC that have 2 differents commands executeUpdate and executeQuery that do the same thing, one expecting to do insert/update while the second return a resultset, to return precise results:
That might have more interest this way |
Since a programmer knows what kind of query he calls this could be passed as a generic param, something like const res: RowArrayResult = await connection.query<RowArrayResult>({ rowsAsArray: true, sql: 'select * from animals' });
const res: RowObjectResult = await connection.query<RowObjectResult>({ sql: 'select * from animals' }); |
definitively a better approch. I've created https://jira.mariadb.org/browse/CONJS-184 for this. |
Do i miss something or JSON type is still now permitted in Typescript ? |
There is no JSON type in TS. Maybe |
Hello, I hope this finds you well.
Please could you add a meaningful return type to
Connection.query()
(specifically, in the TypeScript typing of it)? At the moment, it returns aPromise<any>
. Using anany
value means that the value could be of any type, and defeats the purpose of using typed TypeScript over untyped JavaScript to begin with. As far as I can tell, it will either return anOkPacket
or throw an error. Please could you, therefore, change the return type to something likePromise<OkPacket>
? I don't think anOkPacket
TypeScript class exists right now but, as far as I can tell, it wouldn't be too complex to create.Thank you for your time and consideration.
The text was updated successfully, but these errors were encountered: