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

kysely-singlestore

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kysely-singlestore

Kysely dialects, plugins and other goodies for SingleStore (formerly MemSQL)

  • 0.4.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
decreased by-82.05%
Maintainers
1
Weekly downloads
 
Created
Source

Logo

kysely-singlestore

tests Codacy Badge Powered by TypeScript

Kysely dialects, plugins and other goodies for SingleStore (formerly MemSQL).

Installation

Node.js

NPM 7+
npm i kysely-singlestore
NPM <7
npm i kysely-singlestore kysely
Yarn
yarn add kysely-singlestore kysely
PNPM
pnpm add kysely-singlestore kysely

Deno

This package uses/extends some Kysely types and classes, which are imported using it's NPM package name -- not a relative file path or CDN url.

To fix that, add an import_map.json file.

{
  "imports": {
    "kysely": "https://cdn.jsdelivr.net/npm/kysely@0.22.0/dist/esm/index.js"
  }
}

Usage

Data API Dialect

SingleStore Data API allows executing SQL queries in the browser and is a great fit for serverless functions and other auto-scaling compute services. It does not support transactions at this point in time.

Node.js 16.8+

Older versions of node are also supported, just swap undici with node-fetch.

import {Kysely} from 'kysely'
import {SingleStoreDataApiDialect, SingleStoreDataType} from 'kysely-singlestore'
import {fetch} from 'undici'

interface Database {
  person: {
    id: string
    first_name: string | null
    last_name: string | null
  }
  pet: {
    id: string
    name: string
    owner_id: string
  }
}

const db = new Kysely<Database>({
  dialect: new SingleStoreDataApiDialect({
    database: '<database>',
    deserialization: {
      castDatesAsNativeDates: true,
      castTinyIntAsBoolean: true,
      deserialize: (value, dataType, columnName) =>
        dataType === SingleStoreDataType.Json && columnName === 'pet' ? new Pet(value) : undefined,
      unwrapDecimals: true,
    },
    fetch,
    hostname: '<hostname>',
    password: '<password>',
    username: '<username>',
  }),
})
Browser
import {Kysely} from 'kysely'
import {SingleStoreDataApiDialect, SingleStoreDataType} from 'kysely-singlestore'

interface Database {
  person: {
    id: string
    first_name: string | null
    last_name: string | null
  }
  pet: {
    id: string
    name: string
    owner_id: string
  }
}

const db = new Kysely<Database>({
  dialect: new SingleStoreDataApiDialect({
    database: '<database>',
    deserialization: {
      castDatesAsNativeDates: true,
      castTinyIntAsBoolean: true,
      deserialize: (value, dataType, columnName) =>
        dataType === SingleStoreDataType.Json && columnName === 'pet' ? new Pet(value) : undefined,
      unwrapDecimals: true,
    },
    fetch: window.fetch.bind(window),
    hostname: '<hostname>',
    password: '<password>',
    username: '<username>',
  }),
})
Deno
import {Kysely} from 'https://cdn.jsdelivr.net/npm/kysely@0.22.0/dist/esm/index.js'
import {
  SingleStoreDataApiDialect,
  SingleStoreDataType,
} from 'https://cdn.jsdelivr.net/npm/kysely-singlestore@latest/dist/esm/index.js'

interface Database {
  person: {
    id: string
    first_name: string | null
    last_name: string | null
  }
  pet: {
    id: string
    name: string
    owner_id: string
  }
}

const db = new Kysely<Database>({
  dialect: new SingleStoreDataApiDialect({
    database: '<database>',
    deserialization: {
      castDatesAsNativeDates: true,
      castTinyIntAsBoolean: true,
      deserialize: (value, dataType, columnName) =>
        dataType === SingleStoreDataType.Json && columnName === 'pet' ? new Pet(value) : undefined,
      unwrapDecimals: true,
    },
    fetch: fetch,
    hostname: '<hostname>',
    password: '<password>',
    username: '<username>',
  }),
})

"Classic" Dialect - SoonTM

SingleStore is wire-compatible with MySQL so you can connect to it using mysql2 in node environments, and take advantage of connection pools and transactions.

License

MIT License, see LICENSE

Keywords

FAQs

Package last updated on 10 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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