serverless-mysql
serverless-mysql copied to clipboard
Types definition for Typescript
That's it!
+1
I've tested with [email protected]. It seem to work
I'm only able to import with
import create = require('serverless-mysql')
and my intellisense can't seem to import the type ServerlessMysql - is this expected?
Additionally, the Transaction is actually a function returning that interface, not an object, so the existing type of
transaction: Transaction
should be
transaction(): Transaction
and
commit(): Promise<any>
could be
commit(): Promise<any[]>
@shrugs > import the type ServerlessMysql - is this expected?
Not expected, definition is very initial version, so many modifications will need more.
Can you review the commit? I applied your comment, https://github.com/deptno/serverless-mysql/commit/32df25f2f4d52d4c78a219d32277bda0e38c5c26
Any additional help with TypeScript definitions would be greatly appreciated.
I made these types for my own use. Something like them may be useful in the next iteration of this:
export interface DbQuery {
/**
* Template query
*/
sql: string;
/**
* Values for template query
*/
values?: any[];
timeout: number;
}
/**
* Return type from ServerlessMysql#query after performing a SQL INSERT
*/
export interface DbInsertResult {
insertId: number;
}
/**
* Return type from ServerlessMysql#query after performing a SQL DELETE
*/
export interface DbDeleteResult {
affectedRows: number;
}
/**
* Return type from ServerlessMysql#query after performing a SQL UPDATE
*/
export interface DbUpdateResult {
changedRows: number;
}
/**
* Return type from ServerlessMysql#query after performing a SQL SELECT
* (Array of objects containing the requested table fields.)
*/
export type DbSelectResult = Array<any>;