@polyscale/serverless-js
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

PolyScale Serverless Client

npm (scoped) GitHub Workflow Status GitHub npm bundle size (scoped)

Serverless-js is a lightweight, Fetch API based HTTP client designed for executing SQL over HTTP with PolyScale.ai. Serverless-js is intended for use in serverless environments where TCP based database connections are unavailable e.g. Vercel and Cloudflare Workers.

Install

npm install @polyscale/serverless-js

Usage

TypeScript/ESM:

import {Client} from "@polyscale/serverless-js";

const polyscale = new Client("https://serverless.aws.psedge.global", {
    cacheId: "polyscale-cache-id",
    username: "target-db-username",
    password: "target-db-password",
    database: "target-db-database",
    provider: "mysql",
});

polyscale.query("SELECT 1;").then(result => console.log(result))

Deno:

import {Client} from "npm:@polyscale/serverless-js";

const polyscale = new Client("https://serverless.aws.psedge.global", {
    cacheId: "polyscale-cache-id",
    username: "target-db-username",
    password: "target-db-password",
    database: "target-db-database",
    provider: "mysql",
});

polyscale.query("SELECT 1;").then(result => console.log(result))

Commonjs:

const {Client} = require("@polyscale/serverless-js");

const polyscale = new Client("https://serverless.aws.psedge.global", {
    cacheId: "polyscale-cache-id",
    username: "target-db-username",
    password: "target-db-password",
    database: "target-db-database",
    provider: "mysql",
});

polyscale.query("SELECT 1;").then(result => console.log(result))

Parameter Bindings

See knex documentation for more information.

import {Client} from "@polyscale/serverless-js";

const polyscale = new Client("https://serverless.aws.psedge.global", {
    cacheId: "polyscale-cache-id",
    username: "target-db-username",
    password: "target-db-password",
    database: "target-db-database",
    provider: "mysql",
});

polyscale.query("SELECT * FROM user WHERE name = ?;", ["Peter"]).then(result => console.log(result))
polyscale.query("SELECT * FROM user WHERE name = :name;", {name: "Peter"}).then(result => console.log(result))

Examples

Readme

Keywords

none

Package Sidebar

Install

npm i @polyscale/serverless-js

Weekly Downloads

35

Version

1.4.0

License

none

Unpacked Size

30.1 kB

Total Files

7

Last publish

Collaborators

  • hpohlmeyer
  • jannikkeye
  • polyscaleai