@sqlrooms/motherduck 0.27.0 → 0.28.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 +51 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,8 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
MotherDuck connector for SQLRooms.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
`@sqlrooms/motherduck` exposes a DuckDB connector implementation backed by [`@motherduck/wasm-client`](https://motherduck.com/docs/sql-reference/wasm-client/), so SQLRooms apps can query MotherDuck from the browser.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @sqlrooms/motherduck @sqlrooms/room-shell
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import {createWasmMotherDuckDbConnector} from '@sqlrooms/motherduck';
|
|
15
|
+
import {
|
|
16
|
+
createRoomShellSlice,
|
|
17
|
+
createRoomStore,
|
|
18
|
+
RoomShellSliceState,
|
|
19
|
+
} from '@sqlrooms/room-shell';
|
|
20
|
+
|
|
21
|
+
type RoomState = RoomShellSliceState;
|
|
22
|
+
|
|
23
|
+
export function createStore(mdToken: string) {
|
|
24
|
+
return createRoomStore<RoomState>((set, get, store) => ({
|
|
25
|
+
...createRoomShellSlice({
|
|
26
|
+
connector: createWasmMotherDuckDbConnector({
|
|
27
|
+
mdToken,
|
|
28
|
+
}),
|
|
29
|
+
})(set, get, store),
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Connector options
|
|
35
|
+
|
|
36
|
+
`createWasmMotherDuckDbConnector(options)` accepts:
|
|
37
|
+
|
|
38
|
+
- MotherDuck WASM client connection params (for example `mdToken`)
|
|
39
|
+
- optional `initializationQuery` string to run at connector init
|
|
40
|
+
|
|
41
|
+
## Type guard and advanced access
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import {isWasmMotherDuckDbConnector} from '@sqlrooms/motherduck';
|
|
45
|
+
|
|
46
|
+
const connector = await roomStore.getState().db.getConnector();
|
|
47
|
+
if (isWasmMotherDuckDbConnector(connector)) {
|
|
48
|
+
const connection = connector.getConnection();
|
|
49
|
+
// access low-level MotherDuck WASM connection APIs
|
|
50
|
+
}
|
|
51
|
+
```
|
|
5
52
|
|
|
6
53
|
## Example
|
|
7
54
|
|
|
8
|
-
|
|
55
|
+
- MotherDuck cloud query example: https://github.com/sqlrooms/examples/tree/main/query-motherduck
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/motherduck",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@motherduck/wasm-client": "^0.8.0",
|
|
23
|
-
"@sqlrooms/duckdb": "0.
|
|
23
|
+
"@sqlrooms/duckdb": "0.28.0",
|
|
24
24
|
"apache-arrow": "^17.0.0"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"typecheck": "tsc --noEmit",
|
|
31
31
|
"typedoc": "typedoc"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "dcac54f8adf77240e293c93d224a0ce9fd8142a9"
|
|
34
34
|
}
|