Skip to content

Commit 1647a01

Browse files
committed
Update README
Signed-off-by: Roeniss Moon <roeniss2@gmail.com>
1 parent 8defff1 commit 1647a01

1 file changed

Lines changed: 28 additions & 7 deletions

File tree

spring-batch-notion/README.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,45 @@ implementation("org.springframework.batch.extensions:spring-batch-notion:${sprin
3232

3333
The `NotionDatabaseItemReader` is a restartable `ItemReader` that reads entries from a [Notion Database] via a paging technique.
3434

35+
### Basic Usage (Automatic Data Source Discovery)
36+
3537
A minimal configuration of the item reader is as follows:
3638

3739
```java
3840
NotionDatabaseItemReader<Item> itemReader() {
3941
String token = System.getenv("NOTION_TOKEN");
40-
String databaseId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"; // UUID
42+
String databaseId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"; // Database ID (UUID)
4143
PropertyMapper<Item> propertyMapper = new CustomPropertyMapper();
4244
return new NotionDatabaseItemReader<>(token, databaseId, propertyMapper);
4345
}
4446
```
4547

46-
The following constructor parameters should be provided:
48+
When `dataSourceId` is not provided as shown above, the reader automatically discovers it from the database. The reader will query the database metadata to retrieve the first available data source.
49+
50+
### Advanced Usage (Manual Data Source Selection)
51+
52+
If the given Notion database has multiple data sources, you can specify the data source ID directly:
53+
54+
```java
55+
NotionDatabaseItemReader<Item> itemReader() {
56+
String token = System.getenv("NOTION_TOKEN");
57+
String databaseId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"; // Database ID (UUID)
58+
String dataSourceId = "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY"; // Data Source ID (UUID)
59+
PropertyMapper<Item> propertyMapper = new CustomPropertyMapper();
60+
return new NotionDatabaseItemReader<>(token, databaseId, dataSourceId, propertyMapper);
61+
}
62+
```
63+
64+
### Constructor Parameters
65+
66+
The constructor accepts the following parameters:
4767

48-
| Property | Description |
49-
|------------------|---------------------------------------------------------------------------------------------------------------------------|
50-
| `token` | The Notion integration token. |
51-
| `databaseId` | UUID of the database to read from. |
52-
| `propertyMapper` | The `PropertyMapper` responsible for mapping properties of a Notion item into a Java object. |
68+
| Property | Required | Description |
69+
|------------------|----------|----------------------------------------------------------------------------------------------------------------------------|
70+
| `token` | yes | The Notion integration token. |
71+
| `databaseId` | yes | UUID of the database to read from. |
72+
| `dataSourceId` | no | UUID of the data source to query. If not provided, the reader will automatically discover the first available data source. |
73+
| `propertyMapper` | yes | The `PropertyMapper` responsible for mapping properties of a Notion item into a Java object. |
5374

5475
and the following configuration options are available:
5576

0 commit comments

Comments
 (0)