Socket
Socket
Sign inDemoInstall

libsql-stateless-easy

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libsql-stateless-easy

this makes using libsql-stateless easy


Version published
Weekly downloads
5.9M
decreased by-0.08%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

libsql-stateless-easy

A wrapper for libsql-stateless that provides a much better DX

  • Supported runtime environments: Web API (browser, serverless), Bun, Node.js (>=18)
  • Is built for: Quick stateless query execution. (Mainly for serverless and edge functions.)
  • ⚠️ Supports everything in @libsql/client except (explicit) transactions and local or in-memory DBs.
  • The API provided by libsql-stateless-easy is simple and (almost) exactly the same as @libsql/client.
  • ⚠️ libsql-stateless-easy comes with the cost of (computational and memory) overheads potentially unneeded by you. But is still very very very slim compared to @libsql/client.

For much better performance, consider using libsql-stateless instead: it, however, has a pretty raw and explicit API unappreciated by many developers.

Installation

$ npm i libsql-stateless-easy #pnpm, yarn, etc.
# or
$ bun add libsql-stateless-easy

Client Usage

libsql-stateless-easy's client has the exact same API as @libsql/client/web's client.

    import { createClient } from "libsql-stateless-easy";
    //or
    const { createClient } = require("libsql-stateless-easy");

    const client = createClient({
        url: "https://da-fish-mandible.turso.io",
        authToken: "fksdgfgksdgfksdg.javsdKDGKSBkgsdfg289374dg"
    });
    
    const res = await client.batch([
        {
            sql: "select * from contacts where contact_id = ?;",
            args: [3]
        },
        "select first_name, last_name, email from contacts where contact_id = 2",
        {
            sql: "insert into contacts (contact_id,first_name,last_name,email,phone) values (?,?,?,?,?);",
            args: [6,"glomm","feru","moca@doro.co","001"]
        },
        {
            sql: "delete from contacts where contact_id = :kkl",
            args: {kkl: 6}
        }
    ]);
    console.log(res);

    const res2 = await client.execute({
        sql: "select first_name, last_name, email, contact_id from contacts where contact_id = ?;",
        args: [1]
    });
    console.log(res2);

    const res3 = await client.serverOk();
    if (res3) console.log("Server Compat Check OK");
    else console.error("Server Compat Check NOT OK");

Drizzle

libsql-stateless-easy's client works with drizzle out-of-the-box.

import { createClient } from "libsql-stateless-easy";
import { drizzle } from 'drizzle-orm/libsql';

(async () => {
    const client = createClient({
        url: "https://da-fish-mandible.turso.io",
        authToken: "fksdgfgksdgfksdg.javsdKDGKSBkgsdfg289374dg"
    });

    const db = drizzle(client);
 
    const result = await db.select().from(table_name).all();
    console.log(result);
})();
  • This library has the exact LibsqlError API as @libsql/client

This Documentation is incomplete

I'll complete it when I have more time.

List of other stuff in this library

Feel free to explore them (or even contribute to the documentation!)

import {
    libsqlValueBuilder, libsqlStatementBuilder, libsqlBatchReqStepsBuilder, libsqlBatchReqStepExecCondBuilder, libsqlTransactionBeginStatement,
    libsqlValueParser, libsqlStatementResParser, libsqlBatchStreamResParser, libsqlTransactionBatchStreamResParser,
    libsqlExecute, //has easier API than `libsql-stateless`'s function of the same name
    libsqlBatch, //has easier API than `libsql-stateless`'s function of the same name
    libsqlServerCompatCheck, //has easier API than `libsql-stateless`'s function of the same name,
    libsqlBatchTransaction, libsqlExecuteMultiple
    createClient //used above
} from "libsql-stateless-easy";

Keywords

FAQs

Package last updated on 16 Nov 2023

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc