🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

kysely-surrealdb

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
k

kysely-surrealdb

Kysely dialects, plugins and other goodies for SurrealDB

0.2.0
Version published
Maintainers
1
Created
Issues
8

kysely-surrealdb

Powered by TypeScript

Kysely dialects, plugins and other goodies for SurrealDB.

SurrealQL is based on SQL, so why not? :trollface:

Installation

NPM 7+

npm i kysely-surrealdb

NPM <7

npm i kysely-surrealdb kysely

Yarn

yarn add kysely-surrealdb kysely

PNPM

pnpm add kysely-surrealdb 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

HTTP Dialect

SurrealDB's HTTP endpoints allows executing SurrealQL queries in the browser and is a great fit for serverless functions and other auto-scaling compute services.

Node.js 16.8+

Older node versions are supported as well, just swap undici with node-fetch.

import {Kysely} from 'kysely'
import {SurrealDbHttpDialect} from 'kysely-surrealdb'
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 SurrealDbHttpDialect({
    database: '<database>',
    fetch,
    hostname: '<hostname>',
    namespace: '<namespace>',
    password: '<password>',
    username: '<username>',
  }),
})

Web Socket Dialect - SoonTM

License

MIT License, see LICENSE

FAQs

Package last updated on 15 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