@hpcc-js/wasm-duckdb 1.0.1 → 1.2.0
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 +26 -7
- package/dist/index.js.map +2 -2
- package/package.json +59 -61
- package/src/duckdb.ts +3 -5
- package/types/build/duckdb-browser-eh.worker.d.ts +2 -0
- package/types/build/duckdb-eh.wasm.d.ts +2 -0
- package/types/{duckdb.d.ts → src/duckdb.d.ts} +1 -1
- /package/types/{index.d.ts → src/index.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,20 +1,39 @@
|
|
|
1
|
-
# @hpcc-js/wasm-
|
|
1
|
+
# @hpcc-js/wasm-duckdb
|
|
2
2
|
|
|
3
|
-
This package
|
|
3
|
+
This package rewraps the DuckDB webassembly distribution provided by DuckDB, this is purly a convenience to provide a consistent loading experience with the rest of the @hpcc-js.wasm library.
|
|
4
|
+
See [DuckDB](https://github.com/duckdb/duckdb) and [DuckDB-wasm](https://github.com/duckdb/duckdb-wasm) for more details.
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
7
8
|
```sh
|
|
8
|
-
npm install @hpcc-js/wasm-
|
|
9
|
+
npm install @hpcc-js/wasm-duckdb
|
|
9
10
|
```
|
|
10
11
|
|
|
11
12
|
## Usage
|
|
12
13
|
|
|
13
14
|
```typescript
|
|
14
|
-
import {
|
|
15
|
+
import { DuckDB } from "@hpcc-js/wasm-duckdb";
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
let duckdb = await DuckDB.load();
|
|
18
|
+
const c = await duckdb.db.connect();
|
|
19
|
+
|
|
20
|
+
const data = [
|
|
21
|
+
{ "col1": 1, "col2": "foo" },
|
|
22
|
+
{ "col1": 2, "col2": "bar" },
|
|
23
|
+
];
|
|
24
|
+
await duckdb.db.registerFileText("rows.json", JSON.stringify(data));
|
|
25
|
+
await c.insertJSONFromPath('rows.json', { name: 'rows' });
|
|
26
|
+
|
|
27
|
+
const arrowResult = await c.query("SELECT * FROM read_json_auto('rows.json')");
|
|
28
|
+
const result = arrowResult.toArray().map((row) => row.toJSON());
|
|
29
|
+
expect(result.length).to.equal(data.length);
|
|
30
|
+
for (let i = 0; i < result.length; i++) {
|
|
31
|
+
expect(result[i].col2).to.equal(data[i].col2);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
c.close();
|
|
19
35
|
```
|
|
20
36
|
|
|
37
|
+
## Reference
|
|
38
|
+
|
|
39
|
+
* [API Documentation](https://hpcc-systems.github.io/hpcc-js-wasm/duckdb/src/duckdb/classes/DuckDB.html)
|