Skip to content

Commit

Permalink
Merge pull request #4414 from jraymakers/jray/node-updates
Browse files Browse the repository at this point in the history
updates for node neo
  • Loading branch information
szarnyasg authored Dec 18, 2024
2 parents a739b4c + cae0bed commit 76ea9be
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
// Get the top-3 busiest train stations in May
const duckdb = require('duckdb');
const db = new duckdb.Database(':memory:');
db.all(
import { DuckDBInstance } from '@duckdb/node-api';
const instance = await DuckDBInstance.create();
const connection = await instance.connect();
const reader = await connection.runAndReadAll(
`SELECT station_name, count(*) AS num_services
FROM 'http://blobs.duckdb.org/train_services.parquet'
WHERE monthname(date) = 'May'
GROUP BY ALL
ORDER BY num_services DESC
LIMIT 3;`,
(err, res) => {
if (err) {
console.log("Error", err);
} else {
console.table(res);
}
}
LIMIT 3;`
);
console.table(reader.getRows());
17 changes: 0 additions & 17 deletions _includes/landing-page/nodejs/web-service-integration.js

This file was deleted.

13 changes: 13 additions & 0 deletions _includes/landing-page/nodejs/web-service-integration.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Web Service Integration:
// create endpoint to generate numbers
import express from "express";
import { DuckDBInstance } from '@duckdb/node-api';
const app = express();
const instance = await DuckDBInstance.create();
const connection = await instance.connect();
app.get("/getnumbers", async (req, res) => {
const reader = await connection.runAndReadAll("SELECT random() AS num FROM range(10)");
res.end(JSON.stringify(reader.getRows()));
});

app.listen(8082, () => console.log("Go to: http://localhost:8082/getnumbers"));
2 changes: 1 addition & 1 deletion _includes/quick_installation.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h1>Installation</h1>

<div data-install="nodejs">
{% highlight bash %}
npm install duckdb
npm install @duckdb/node-api
{% endhighlight %}
</div>

Expand Down
3 changes: 2 additions & 1 deletion data/installation-data-1.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
platform: all
download_method: Package manager
architecture: universal
installation_code: npm install duckdb
installation_code: npm install @duckdb/node-api
- variant: stable
environment: Rust
platform: all
Expand Down Expand Up @@ -302,6 +302,7 @@
download_method: Package manager
architecture: universal
installation_code: npm install duckdb@next
note: The nightly release of the Node.js driver installs the old Node.js driver and not DuckDB Node Neo. For the Node Neo driver, the nightly release is currently not available.
- variant: nightly
environment: C/C++
platform: Windows
Expand Down
4 changes: 3 additions & 1 deletion docs/api/node_neo/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Node.js API (Neo)

An API for using [DuckDB](https://duckdb.org/) in [Node.js](https://nodejs.org/).

This is a high-level API meant for applications.
The primary package, [@duckdb/duckdb-api](https://www.npmjs.com/package/@duckdb/node-api), is a high-level API meant for applications.
It depends on low-level bindings that adhere closely to [DuckDB's C API](https://duckdb.org/docs/api/c/overview),
available separately as [@duckdb/duckdb-bindings](https://www.npmjs.com/package/@duckdb/node-bindings).

Expand All @@ -32,8 +32,10 @@ Some features are not yet complete:

### Supported Platforms

- Linux arm64 (experimental)
- Linux x64
- Mac OS X (Darwin) arm64 (Apple Silicon)
- Mac OS X (Darwin) x64 (Intel)
- Windows (Win32) x64

## Examples
Expand Down
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ <h3>{{ event.title }}</h3>

<!-- ------------------- Node.js -------------------- -->

<div data-language="nodejs" data-example="nodejs-sql-query" data-buttontxt="Node.js documentation" data-buttonurl="/docs/api/nodejs/overview">
<div data-language="nodejs" data-example="nodejs-sql-query" data-buttontxt="Node.js documentation" data-buttonurl="/docs/api/node_neo/overview">
{% highlight javascript %}
{% include landing-page/nodejs/sql-query.js %}
{% include landing-page/nodejs/sql-query.mjs %}
{% endhighlight %}
</div>

<div data-language="nodejs" data-example="nodejs-web-service-integration" data-buttontxt="Node.js documentation" data-buttonurl="/docs/api/nodejs/overview">
<div data-language="nodejs" data-example="nodejs-web-service-integration" data-buttontxt="Node.js documentation" data-buttonurl="/docs/api/node_neo/overview">
{% highlight javascript %}
{% include landing-page/nodejs/web-service-integration.js %}
{% include landing-page/nodejs/web-service-integration.mjs %}
{% endhighlight %}
</div>

Expand Down

0 comments on commit 76ea9be

Please sign in to comment.