JavaScript SDK

The JavaScript SDK provides useful utilities to interact with the Airplane platform.

Installation

The Airplane JavaScript SDK is available as an NPM package airplane.
bash
Copied
1
$ npm install airplane

Basic usage

Here is a simple example of how the SDK can be used to:
  1. Select users from a database filtered by name
  2. Display the selected users in a table
  3. Return the number of users that matched
typescript
Copied
1
import airplane from "airplane";
2
3
export default airplane.task(
4
{
5
slug: "lookup_users",
6
name: "Lookup users",
7
parameters: {
8
name: "shorttext",
9
},
10
resources: ["demo_db"],
11
},
12
async (params) => {
13
console.log(`Looking up users like '${params.name}'`);
14
const run = await airplane.sql.query<{
15
id: string;
16
name: string;
17
email: string;
18
}>(
19
"demo_db",
20
`
21
select id, name, email from users
22
where (name ilike :name or email ilike :name)
23
order by name asc
24
`,
25
{ args: { name: `%${params.name}%` } }
26
);
27
28
const users = run.output.Q1;
29
await airplane.display.table(users);
30
31
return {
32
numUsers: users.length,
33
};
34
}
35
);

Concepts

The SDK reference is broken out into pages for each concept. For details and examples, see the pages below.