Skip to content

Commit a3e5e25

Browse files
committed
Fix example in readme
1 parent c95a568 commit a3e5e25

File tree

1 file changed

+15
-29
lines changed

1 file changed

+15
-29
lines changed

README.md

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,34 @@ Experimental [chDB](https://github.com/chdb-io/chdb) FFI bindings for the [bun r
1414

1515
#### Build binding
1616
```bash
17-
bun install chdb-bun
17+
bun run build
18+
bun run example.ts
1819
```
1920

2021
#### Usage
2122

22-
#### Query Constructor
23-
```js
24-
import { db } from 'chdb-bun';
25-
26-
const conn = new db('CSV')
27-
console.log(conn.query("SELECT version()"));
28-
```
29-
30-
#### Query _(query, *format)_
23+
#### Query(query, *format) (ephemeral)
3124
```javascript
32-
import { db } from 'chdb-bun';
33-
const conn = new db('CSV')
25+
import { query } from 'chdb-bun';
3426

3527
// Query (ephemeral)
36-
var result = conn.query("SELECT version()", "CSV");
37-
console.log(result) // 23.10.1.1
28+
var result = query("SELECT version()", "CSV");
29+
console.log(result); // 23.10.1.1
3830
```
3931

40-
#### Session _(query, *format, *path)_
32+
#### Session.Query(query, *format)
4133
```javascript
42-
import { db } from 'chdb-bun';
43-
const conn = new db('CSV', '/tmp')
34+
import { Session } from 'chdb-bun';
35+
const sess = new Session('./chdb-bun-tmp');
4436

4537
// Query Session (persistent)
46-
conn.session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'");
47-
result = conn.session("SELECT hello()", "CSV");
48-
console.log(result)
49-
```
38+
sess.query("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'Hello chDB'", "CSV");
39+
var result = sess.query("SELECT hello()", "CSV");
40+
console.log(result);
5041

51-
> ⚠️ Sessions persist table data to disk. You can specify `path` to implement auto-cleanup strategies:
52-
```javascript
53-
const temperment = require("temperment");
54-
const tmp = temperment.directory();
55-
conn.session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'", "CSV", tmp)
56-
var result = = chdb.Session("SELECT hello();")
57-
console.log(result) // chDB
58-
tmp.cleanup.sync();
42+
// Before cleanup, you can find the database files in `./chdb-bun-tmp`
43+
44+
sess.cleanup(); // cleanup session, this will delete the database
5945
```
6046

6147
<br>

0 commit comments

Comments
 (0)