Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@planetscale/database

Package Overview
Dependencies
Maintainers
4
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@planetscale/database - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

7

dist/index.d.ts

@@ -24,5 +24,6 @@ export { format } from './sanitization.js';

export interface Config {
username: string;
password: string;
host: string;
url?: string;
username?: string;
password?: string;
host?: string;
fetch?: (input: string, init?: ReqInit) => Promise<Pick<Response, 'ok' | 'json' | 'status' | 'statusText' | 'text'>>;

@@ -29,0 +30,0 @@ format?: (query: string, args: any) => string;

@@ -18,7 +18,14 @@ import { format } from './sanitization.js';

constructor(config) {
var _a;
this.session = null;
this.config = { ...config };
if (typeof fetch !== 'undefined') {
config = { fetch, ...config };
(_a = this.config).fetch || (_a.fetch = fetch);
}
this.config = config;
this.session = null;
if (config.url) {
const url = new URL(config.url);
this.config.username = url.username;
this.config.password = url.password;
this.config.host = url.hostname;
}
}

@@ -25,0 +32,0 @@ async refresh() {

{
"name": "@planetscale/database",
"version": "0.2.0",
"version": "0.3.0",
"description": "A JavaScript client for PlanetScale databases.",

@@ -30,3 +30,4 @@ "main": "dist/index.js",

"test": "jest",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"postpublish": "npm publish --ignore-scripts --@planetscale:registry='https://npm.pkg.github.com'"
},

@@ -33,0 +34,0 @@ "repository": {

@@ -22,3 +22,3 @@ # PlanetScale database client

const conn = await connect(config)
const conn = connect(config)
const results = await conn.execute('select 1 from dual where 1=?', [1])

@@ -28,2 +28,16 @@ console.log(results)

### Database URL
A single database URL value can be used to configure the `host`, `username`, and `password` values.
```ts
import { connect } from '@planetscale/database'
const config = {
url: process.env['DATABASE_URL'] || 'mysql://user:pass@aws.connect.psdb.cloud'
}
const conn = connect(config)
```
### Connection factory

@@ -64,3 +78,3 @@

const conn = await connect(config)
const conn = connect(config)
const results = await conn.execute('select 1 from dual')

@@ -85,3 +99,3 @@ console.log(results)

const conn = await connect(config)
const conn = connect(config)
const results = await conn.execute('select 1 from dual where 1=?', [42])

@@ -88,0 +102,0 @@ console.log(results)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc