@neondatabase/serverless
Advanced tools
Comparing version 0.10.1 to 0.10.2
@@ -0,1 +1,5 @@ | ||
## 0.10.2 (2024-11-05) | ||
Expose `types` property on public HTTPQueryOptions type | ||
## 0.10.1 (2024-10-07) | ||
@@ -2,0 +6,0 @@ |
@@ -111,2 +111,25 @@ # Options and configuration | ||
### `types: typeof PgTypes` | ||
The `types` option can be passed to `neon(...)` to override the default PostgreSQL type parsers provided by `PgTypes`. This is useful if you want to define custom parsing behavior for specific PostgreSQL data types, allowing you to control how data is converted when retrieved from the database. Learn more in the [PgTypes official documentation](https://github.com/brianc/node-pg-types). | ||
Example of usage: | ||
```typescript | ||
import PgTypes from 'pg-types'; | ||
import { neon } from '@neondatabase/serverless'; | ||
// Define custom parsers for specific PostgreSQL types | ||
// Parse PostgreSQL `DATE` fields as JavaScript `Date` objects | ||
PgTypes.setTypeParser(PgTypes.builtins.DATE, (val) => new Date(val)); | ||
// Parse PostgreSQL `NUMERIC` fields as JavaScript `float` values | ||
PgTypes.setTypeParser(PgTypes.builtins.NUMERIC, parseFloat); | ||
// Configure the Neon client with the custom `types` parser | ||
const sql = neon(process.env.DATABASE_URL, { | ||
types: PgTypes, // Pass in the custom PgTypes object here | ||
}); | ||
``` | ||
### `authToken: string | (() => Promise<string> | string)` | ||
@@ -113,0 +136,0 @@ |
@@ -166,2 +166,3 @@ | ||
PoolClient as PgPoolClient, | ||
types as PgTypes | ||
} from "pg"; | ||
@@ -244,2 +245,8 @@ | ||
authToken?: string | (() => Promise<string> | string); | ||
/** | ||
* Custom type parsers | ||
* See https://github.com/brianc/node-pg-types | ||
*/ | ||
types?: typeof PgTypes; | ||
} | ||
@@ -246,0 +253,0 @@ |
{ | ||
"name": "@neondatabase/serverless", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"author": "Neon", | ||
@@ -5,0 +5,0 @@ "description": "node-postgres for serverless environments from neon.tech", |
Sorry, the diff of this file is not supported yet
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
349131
3670