limbo/bindings/javascript
Pekka Enberg 9a27583dd7 Merge 'bindings/javascript: Formatting and typos' from Mikaël Francoeur
This is a follow-up PR to
https://github.com/tursodatabase/turso/pull/1907#discussion_r2175959782.
I had my formatter set to `prettier` instead of `tsserver`, which seems
to be what the team is using.
So I:
* removed the `prettier-ignore` comments that I added in the other PR;
* formatted js files using `tsserver`;
* formatted md files using `prettier` (it just makes the tables nicer);
* fixed some typos;
* added some formatting info to `CONTRIBUTING.md`.
-----
as part of https://github.com/tursodatabase/turso/issues/1900

Closes #1914
2025-07-02 19:32:30 +03:00
..
.yarn/releases Initial JavaScript bindings with napi-rs 2025-03-26 13:30:13 +02:00
__test__ format js files using tsserver 2025-07-01 11:05:26 -04:00
docs add formatting instructions for js 2025-07-01 11:11:36 -04:00
npm Turso 0.1.1 2025-06-30 23:58:04 +03:00
src Rename limbo_core crate to turso_core 2025-06-29 09:59:17 +03:00
.gitignore Initial JavaScript bindings with napi-rs 2025-03-26 13:30:13 +02:00
.npmignore Initial JavaScript bindings with napi-rs 2025-03-26 13:30:13 +02:00
.yarnrc.yml Initial JavaScript bindings with napi-rs 2025-03-26 13:30:13 +02:00
build.rs Initial JavaScript bindings with napi-rs 2025-03-26 13:30:13 +02:00
Cargo.toml Rename limbo_core crate to turso_core 2025-06-29 09:59:17 +03:00
index.d.ts bind/js: Add tests and some fixes 2025-05-08 15:57:46 -03:00
index.js bindings/javascript: Rename package to @tursodatabase/turso 2025-06-27 12:14:16 +03:00
package-lock.json Turso 0.1.1 2025-06-30 23:58:04 +03:00
package.json Turso 0.1.1 2025-06-30 23:58:04 +03:00
README.md add a basic readme for the typescript binding 2025-07-02 10:03:53 -05:00
wrapper.js bindings/javascript: implement readonly functionality 2025-06-25 18:36:52 +03:00
yarn.lock bindings/javascript: Regenerate yarn.lock 2025-06-30 11:25:24 +03:00

@tursodatabase/turso

The next evolution of SQLite: A high-performance, SQLite-compatible database library for Node.js

Features

  • SQLite Compatible: Drop-in replacement for better-sqlite3 with familiar API
  • High Performance: Built with Rust for maximum speed and efficiency
  • In-Process: No network overhead, runs directly in your Node.js process
  • TypeScript Support: Full TypeScript definitions included
  • Cross-Platform: Supports Linux, macOS, and Windows
  • Transaction Support: Full ACID transactions with rollback support
  • Prepared Statements: Optimized query execution with parameter binding

Installation

npm install @tursodatabase/turso

Quick Start

In-Memory Database

import { Database } from '@tursodatabase/turso';

// Create an in-memory database
const db = new Database(':memory:');

// Create a table
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');

// Insert data
const insert = db.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
insert.run('Alice', 'alice@example.com');
insert.run('Bob', 'bob@example.com');

// Query data
const users = db.prepare('SELECT * FROM users').all();
console.log(users);
// Output: [
//   { id: 1, name: 'Alice', email: 'alice@example.com' },
//   { id: 2, name: 'Bob', email: 'bob@example.com' }
// ]

File-Based Database

import { Database } from '@tursodatabase/turso';

// Create or open a database file
const db = new Database('my-database.db');

// Create a table
db.exec(`
  CREATE TABLE IF NOT EXISTS posts (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT NOT NULL,
    content TEXT,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP
  )
`);

// Insert a post
const insertPost = db.prepare('INSERT INTO posts (title, content) VALUES (?, ?)');
const result = insertPost.run('Hello World', 'This is my first blog post!');

console.log(`Inserted post with ID: ${result.lastInsertRowid}`);

API Reference

License

MIT

Support