1.6.8 • Published 2 months ago

libsql-stateless-easy v1.6.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

libsql-stateless-easy

Thin libSQL stateless HTTP driver for TypeScript and JavaScript for the edge but easy 🚀

  • Supported runtime environments: Web API (browser, serverless), Bun, Node.js (>=18)
  • Is extremely light: 38.8kB (unpacked)/ 10.9kB (package)/ 10.2KB (minified)/ 3.7KB (minified+gzipped)
  • Is built for: Quick stateless query execution. (Mainly for serverless and edge functions.)
  • ✅ Supports everything in @libsql/client/web **except interactive transactions.
  • ✅ Unlike @libsql/client/web, every function performs complete execution in exactly 1 roundtrip.
  • libsql-stateless-easy is simply a drop-in replacement and exactly same API as @libsql/client/web.

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

List of other stuff in this library

Feel free to explore them (however you dont need to as they've been neatly packaged into the client)

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";

API Level

NOTE: current API level is that of latest stable libsql-stateless.
Read this section.

1.6.8

2 months ago

1.6.4

2 months ago

1.6.3

2 months ago

1.6.2

2 months ago

1.6.1

2 months ago

1.6.0

2 months ago

1.6.0-alpha.1

2 months ago

1.6.0-alpha.2

2 months ago

1.6.2-alpha.2

2 months ago

1.6.2-alpha.1

2 months ago

1.6.7

2 months ago

1.6.6

2 months ago

1.6.5

2 months ago

1.5.8

3 months ago

1.5.7

3 months ago

1.5.6

3 months ago

1.5.4

4 months ago

1.5.3

4 months ago

1.5.2

5 months ago

1.5.1

5 months ago

1.5.0

5 months ago

1.4.6

7 months ago

1.3.7

8 months ago

1.4.5

7 months ago

1.3.6

8 months ago

1.4.4

7 months ago

1.3.5

8 months ago

1.4.3

7 months ago

1.3.4

8 months ago

1.4.2

7 months ago

1.3.3

8 months ago

1.4.1

7 months ago

1.3.2

8 months ago

1.4.0

7 months ago

1.3.1

8 months ago

1.3.0

8 months ago

1.4.8

7 months ago

1.3.9

7 months ago

1.4.7

7 months ago

1.3.8

8 months ago

1.2.1

8 months ago

1.2.0

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago