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

Types definition for Typescript #5

Closed
xamoulin opened this issue Sep 11, 2018 · 7 comments
Closed

Types definition for Typescript #5

xamoulin opened this issue Sep 11, 2018 · 7 comments
Labels
enhancement New feature or request

Comments

@xamoulin
Copy link

That's it!

@jeremydaly jeremydaly added the enhancement New feature or request label Oct 1, 2018
@liam-betsworth
Copy link

+1

jeremydaly added a commit that referenced this issue Apr 24, 2019
#5 add typescript definition
@deptno
Copy link
Contributor

deptno commented Apr 25, 2019

I've tested with serverless@1.3.0. It seem to work

@shrugs
Copy link
Contributor

shrugs commented Apr 26, 2019

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?

@shrugs
Copy link
Contributor

shrugs commented Apr 26, 2019

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[]>

deptno added a commit to deptno/serverless-mysql that referenced this issue Apr 27, 2019
…n object -> function, commit returns array type
@deptno
Copy link
Contributor

deptno commented Apr 27, 2019

@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, deptno@32df25f

@jeremydaly
Copy link
Owner

Any additional help with TypeScript definitions would be greatly appreciated.

deptno added a commit to deptno/serverless-mysql that referenced this issue Apr 28, 2019
@kernwig
Copy link

kernwig commented Jun 4, 2019

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>;

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

No branches or pull requests

7 participants