JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 77946
  • Score
    100M100P100Q211385F
  • License Apache-2.0

A JavaScript client for PlanetScale databases.

Package Exports

  • @planetscale/database
  • @planetscale/database/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@planetscale/database) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

PlanetScale database client

A JavaScript client for PlanetScale databases.

Installation

$ npm install @planetscale/database

Usage

import { connect } from '@planetscale/database'

const config = {
  host: 'aws.connect.psdb.cloud',
  username: '<user>',
  password: '<password>'
}

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

Connection factory

Use the Client connection factory class to create fresh connections for each transaction or web request handler.

import { Client } from '@planetscale/database'

const client = new Client({
  host: 'aws.connect.psdb.cloud',
  username: '<user>',
  password: '<password>'
})

const conn = await client.connection()
const results = await conn.execute('select 1 from dual')
console.log(results)

Custom fetch function

Node.js version 18 includes a built-in global fetch function. When using an older version of Node.js, you can provide a custom fetch function implementation. We recommend the undici package on which Node's built-in fetch is based.

import { connect } from '@planetscale/database'
import { fetch } from 'undici'

const config = {
  fetch,
  host: 'aws.connect.psdb.cloud',
  username: '<user>',
  password: '<password>'
}

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

Development

npm install
npm test

License

Distributed under the Apache 2.0 license. See LICENSE for details.