@planetscale/database
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -21,4 +21,4 @@ export { format } from './sanitization.js'; | ||
statement: string; | ||
insertId: string | null; | ||
rowsAffected: number | null; | ||
insertId: string; | ||
rowsAffected: number; | ||
time: number; | ||
@@ -63,2 +63,3 @@ } | ||
as?: ExecuteAs; | ||
cast?: Cast; | ||
}; | ||
@@ -65,0 +66,0 @@ declare type ExecuteArgs = object | any[] | null; |
@@ -80,4 +80,4 @@ import { format } from './sanitization.js'; | ||
} | ||
const rowsAffected = result?.rowsAffected ? parseInt(result.rowsAffected, 10) : null; | ||
const insertId = result?.insertId ?? null; | ||
const rowsAffected = result?.rowsAffected ? parseInt(result.rowsAffected, 10) : 0; | ||
const insertId = result?.insertId ?? '0'; | ||
this.session = session; | ||
@@ -88,3 +88,4 @@ const fields = result?.fields ?? []; | ||
} | ||
const rows = result ? parse(result, this.config.cast || cast, options.as || 'object') : []; | ||
const castFn = options.cast || this.config.cast || cast; | ||
const rows = result ? parse(result, castFn, options.as || 'object') : []; | ||
const headers = fields.map((f) => f.name); | ||
@@ -91,0 +92,0 @@ const typeByName = (acc, { name, type }) => ({ ...acc, [name]: type }); |
@@ -1,1 +0,1 @@ | ||
export declare const Version = "1.5.0"; | ||
export declare const Version = "1.6.0"; |
@@ -1,1 +0,1 @@ | ||
export const Version = '1.5.0'; | ||
export const Version = '1.6.0'; |
{ | ||
"name": "@planetscale/database", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "A Fetch API-compatible PlanetScale database driver", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
@@ -8,0 +8,0 @@ "dist" |
@@ -156,2 +156,19 @@ # PlanetScale Serverless Driver for JavaScript | ||
You can also pass a custom `cast` function to `execute`. If present, this will override the `cast` function set by the connection: | ||
```ts | ||
const result = await conn.execute( | ||
'SELECT userId, SUM(balance) AS balance FROM UserBalanceItem GROUP BY userId', | ||
{}, | ||
{ | ||
cast: (field, value) => { | ||
if (field.name === 'balance') { | ||
return BigInt(value) | ||
} | ||
return cast(field, value) | ||
} | ||
} | ||
) | ||
``` | ||
### Row return values | ||
@@ -158,0 +175,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30604
388
196