fermyon / spin-js-sdk

https://developer.fermyon.com/spin/javascript-components
Apache License 2.0
52 stars 18 forks source link

SqliteReturn type uses tuple with union type instead of an array type #183

Closed maxicapodacqua closed 1 year ago

maxicapodacqua commented 1 year ago

The SqliteReturn type uses a tuple for the rows:

interface SqliteReturn {
    columns: string[],
    rows: [
        [SqliteValue]
    ]
}

This makes parsing results more complicated when you need to manipulate it as an array (when you expect more than one row. I suggest changing the response type to be:

interface SqliteReturn {
    columns: string[],
    rows: SqliteValue[]
}

Or maybe something more suitable for different types, following the example of Planetscale: https://github.com/planetscale/database-js/blob/488e48b04cfb25b001050d6dbeebe8dd9b0a6f65/src/index.ts#L7

type Row = Record<string, any> | any[]
karthik2804 commented 1 year ago

Thanks for reporting this @maxicapodacqua - We will look into switching to something similar to Planetscale.