Skip to content

Commit 7f83aa5

Browse files
authored
Merge pull request #49 from classmethod/add-jsdoc
2 parents db400a7 + 0db059a commit 7f83aa5

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ yarn add @classmethod/athena-query @aws-sdk/client-athena
2626

2727
### Basic Usage
2828

29-
Athena-Query provide [async generator function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function*).
29+
Athena-Query provide `query()` method as [async generator function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function*).
3030
So we can use it with `for await () {}`,
3131

3232
```ts
@@ -43,6 +43,8 @@ for await (const item of athenaQuery.query("SELECT * FROM waf_logs;")) {
4343

4444
And if you break loop out, Athena-Query don't call unnecessary pages of `get-query-result` api.
4545

46+
If you want to reduce the size of the queried data rather than the retrieved data, you can use the [LIMIT clause](https://docs.aws.amazon.com/athena/latest/ug/select.html#select-parameters).
47+
4648
### Options
4749

4850
When you initialize AthenaQuery class, you can pass options to specify the query target.
@@ -65,7 +67,6 @@ const resultGen = athenaQuery.query(
6567
`,
6668
{
6769
executionParameters: ["test", 123, 456n],
68-
maxResults: 100,
6970
}
7071
);
7172
```

lib/athena-query.ts

+32-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@ import * as helpers from "./helper";
22
import type { Athena } from "@aws-sdk/client-athena";
33

44
type Options = {
5-
db?: string;
5+
/**
6+
* The name of the workgroup in which the query is being started.
7+
*/
68
workgroup?: string;
9+
10+
/**
11+
* The name of the database used in the query execution.
12+
* The database must exist in the catalog.
13+
*/
14+
db?: string;
15+
16+
/**
17+
* The name of the data catalog used in the query execution.
18+
*/
719
catalog?: string;
820
};
921

@@ -13,10 +25,29 @@ export class AthenaQuery {
1325
private readonly options?: Options
1426
) {}
1527

28+
/**
29+
* @see https://github.com/classmethod/athena-query#usage
30+
*
31+
* @param sql
32+
* @param options
33+
*/
1634
async *query(
1735
sql: string,
1836
options?: {
37+
/**
38+
* A list of values for the parameters in a query.
39+
* The values are applied sequentially to the parameters in the query in the order in which the parameters occur.
40+
*/
1941
executionParameters?: (string | number | BigInt)[];
42+
43+
/**
44+
* The maximum number of results (rows) to return in this request.
45+
*
46+
* @deprecated We recommend you to use LIMIT clause in SQL.
47+
* Because even if you set it, athena-query will continue to retrieve results unless you break your for-loop.
48+
*
49+
* @see https://docs.aws.amazon.com/athena/latest/ug/select.html#select-parameters
50+
*/
2051
maxResults?: number;
2152
}
2253
): AsyncGenerator<helpers.AtheneRecordData, void, undefined> {

0 commit comments

Comments
 (0)