@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 CHANGED
@@ -1,20 +1,39 @@
1
- # @hpcc-js/wasm-graphviz
1
+ # @hpcc-js/wasm-duckdb
2
2
 
3
- This package provides a WebAssembly wrapper around the [Graphviz](https://www.graphviz.org/) library. This allows for the rendering of DOT language graphs directly within a browser or NodeJS type environment.
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-graphviz
9
+ npm install @hpcc-js/wasm-duckdb
9
10
  ```
10
11
 
11
12
  ## Usage
12
13
 
13
14
  ```typescript
14
- import { Graphviz } from "@hpcc-js/wasm-graphviz";
15
+ import { DuckDB } from "@hpcc-js/wasm-duckdb";
15
16
 
16
- const graphviz = await Graphviz.load();
17
- const svg = graphviz.dot(`digraph { a -> b; }`);
18
- document.body.innerHTML = svg;
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)