@tursodatabase/database 0.1.4-pre.7 → 0.1.4-pre.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,16 +1,29 @@
1
- # @tursodatabase/database
1
+ <p align="center">
2
+ <h1 align="center">Turso Database for JavaScript</h1>
3
+ </p>
2
4
 
3
- The next evolution of SQLite: A high-performance, SQLite-compatible database library for Node.js
5
+ <p align="center">
6
+ <a title="JavaScript" target="_blank" href="https://www.npmjs.com/package/@tursodatabase/database"><img alt="npm" src="https://img.shields.io/npm/v/@tursodatabase/database"></a>
7
+ <a title="MIT" target="_blank" href="https://github.com/tursodatabase/turso/blob/main/LICENSE.md"><img src="http://img.shields.io/badge/license-MIT-orange.svg?style=flat-square"></a>
8
+ </p>
9
+ <p align="center">
10
+ <a title="Users Discord" target="_blank" href="https://tur.so/discord"><img alt="Chat with other users of Turso on Discord" src="https://img.shields.io/discord/933071162680958986?label=Discord&logo=Discord&style=social"></a>
11
+ </p>
12
+
13
+ ---
14
+
15
+ ## About
16
+
17
+ This package is the Turso in-memory database library for JavaScript.
18
+
19
+ > **⚠️ Warning:** This software is ALPHA, only use for development, testing, and experimentation. We are working to make it production ready, but do not use it for critical data right now.
4
20
 
5
21
  ## Features
6
22
 
7
- - **SQLite Compatible**: Drop-in replacement for better-sqlite3 with familiar API
8
- - **High Performance**: Built with Rust for maximum speed and efficiency
9
- - **In-Process**: No network overhead, runs directly in your Node.js process
10
- - **TypeScript Support**: Full TypeScript definitions included
11
- - **Cross-Platform**: Supports Linux, macOS, Windows and browsers (through WebAssembly)
12
- - **Transaction Support**: Full ACID transactions with rollback support
13
- - **Prepared Statements**: Optimized query execution with parameter binding
23
+ - **SQLite compatible:** SQLite query language and file format support ([status](https://github.com/tursodatabase/turso/blob/main/COMPAT.md)).
24
+ - **In-process**: No network overhead, runs directly in your Node.js process
25
+ - **TypeScript support**: Full TypeScript definitions included
26
+ - **Cross-platform**: Supports Linux, macOS, Windows and browsers (through WebAssembly)
14
27
 
15
28
  ## Installation
16
29
 
@@ -18,15 +31,15 @@ The next evolution of SQLite: A high-performance, SQLite-compatible database lib
18
31
  npm install @tursodatabase/database
19
32
  ```
20
33
 
21
- ## Quick Start
34
+ ## Getting Started
22
35
 
23
36
  ### In-Memory Database
24
37
 
25
38
  ```javascript
26
- import Database from '@tursodatabase/database';
39
+ import { connect } from '@tursodatabase/database';
27
40
 
28
41
  // Create an in-memory database
29
- const db = new Database(':memory:');
42
+ const db = await connect(':memory:');
30
43
 
31
44
  // Create a table
32
45
  db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');
@@ -48,10 +61,10 @@ console.log(users);
48
61
  ### File-Based Database
49
62
 
50
63
  ```javascript
51
- import Database from '@tursodatabase/database';
64
+ import { connect } from '@tursodatabase/database';
52
65
 
53
66
  // Create or open a database file
54
- const db = new Database('my-database.db');
67
+ const db = await connect('my-database.db');
55
68
 
56
69
  // Create a table
57
70
  db.exec(`
@@ -70,13 +83,47 @@ const result = insertPost.run('Hello World', 'This is my first blog post!');
70
83
  console.log(`Inserted post with ID: ${result.lastInsertRowid}`);
71
84
  ```
72
85
 
86
+ ### Transactions
87
+
88
+ ```javascript
89
+ import { connect } from '@tursodatabase/database';
90
+
91
+ const db = await connect('transactions.db');
92
+
93
+ // Using transactions for atomic operations
94
+ const transaction = db.transaction((users) => {
95
+ const insert = db.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
96
+ for (const user of users) {
97
+ insert.run(user.name, user.email);
98
+ }
99
+ });
100
+
101
+ // Execute transaction
102
+ transaction([
103
+ { name: 'Alice', email: 'alice@example.com' },
104
+ { name: 'Bob', email: 'bob@example.com' }
105
+ ]);
106
+ ```
107
+
108
+ ### WebAssembly Support
109
+
110
+ Turso Database can run in browsers using WebAssembly. Check the `browser.js` and WASM artifacts for browser usage.
111
+
73
112
  ## API Reference
113
+
114
+ For complete API documentation, see [JavaScript API Reference](../../docs/javascript-api-reference.md).
115
+
116
+ ## Related Packages
117
+
118
+ * The [@tursodatabase/serverless](https://www.npmjs.com/package/@tursodatabase/serverless) package provides a serverless driver with the same API.
119
+ * The [@tursodatabase/sync](https://www.npmjs.com/package/@tursodatabase/sync) package provides bidirectional sync between a local Turso database and Turso Cloud.
120
+
74
121
  ## License
75
122
 
76
- MIT
123
+ This project is licensed under the [MIT license](../../LICENSE.md).
77
124
 
78
125
  ## Support
79
126
 
80
127
  - [GitHub Issues](https://github.com/tursodatabase/turso/issues)
81
128
  - [Documentation](https://docs.turso.tech)
82
- - [Discord Community](https://discord.gg/turso)
129
+ - [Discord Community](https://tur.so/discord)
package/dist/promise.js CHANGED
@@ -349,4 +349,14 @@ class Statement {
349
349
  }
350
350
  }
351
351
  }
352
- export { Database, SqliteError };
352
+ /**
353
+ * Creates a new database connection asynchronously.
354
+ *
355
+ * @param {string} path - Path to the database file.
356
+ * @param {Object} opts - Options for database behavior.
357
+ * @returns {Promise<Database>} - A promise that resolves to a Database instance.
358
+ */
359
+ async function connect(path, opts = {}) {
360
+ return new Database(path, opts);
361
+ }
362
+ export { Database, SqliteError, connect };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tursodatabase/database",
3
- "version": "0.1.4-pre.7",
3
+ "version": "0.1.4-pre.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/tursodatabase/turso"
@@ -60,9 +60,9 @@
60
60
  }
61
61
  },
62
62
  "optionalDependencies": {
63
- "@tursodatabase/database-linux-x64-gnu": "0.1.4-pre.7",
64
- "@tursodatabase/database-win32-x64-msvc": "0.1.4-pre.7",
65
- "@tursodatabase/database-darwin-universal": "0.1.4-pre.7",
66
- "@tursodatabase/database-wasm32-wasi": "0.1.4-pre.7"
63
+ "@tursodatabase/database-linux-x64-gnu": "0.1.4-pre.8",
64
+ "@tursodatabase/database-win32-x64-msvc": "0.1.4-pre.8",
65
+ "@tursodatabase/database-darwin-universal": "0.1.4-pre.8",
66
+ "@tursodatabase/database-wasm32-wasi": "0.1.4-pre.8"
67
67
  }
68
68
  }