Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/litencatt/notion-db-auto-relator


https://github.com/litencatt/notion-db-auto-relator

notion notion-database

Last synced: 18 days ago
JSON representation

Awesome Lists containing this project

README

        

# notion-db-auto-relator
Create and update relation for Parent and Child DB in Notion automatically.

## Usage
### Setup in Notion

1. Create a parent DB and a child DB that you want to relate automatically.
1. Duplicate this settings DB.
- https://litencatt.notion.site/3dd1ccec8f0740cc90600de413261fdc
1. Create Notion API Integration.
- https://www.notion.so/my-integrations
1. Invite the API Integration to settings DB, Parent DB and Child DB.

### Run `notion-db-auto-relator `locally
```
$ git clone [email protected]:litencatt/notion-db-auto-relator.git
$ cd notion-db-auto-relator
$ yarn
$ NOTION_TOKEN=*** SETTINGS_DB_ID=*** yarn start
```

### Run `notion-db-auto-relator` as GitHub Actions
settings example

```yaml
on:
workflow_dispatch:
schedule:
- cron: '00 * * * *'

jobs:
run-job:
name: run relation
runs-on: ubuntu-latest
env:
TZ: Asia/Tokyo
LANG: ja_JP.UTF-8
steps:
- uses: actions/checkout@v2
- name: Relation
uses: litencatt/notion-db-auto-relator@main
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
SETTINGS_DB_ID: ${{ secrets.SETTINGS_DB_ID }}
```
### Settings DB examples and relation results
#### Settings DB set values like this,

image

#### Parent DB and Child DB example
image

#### Settings1 relation execute result
Settings1 ✅ and `Run actions` or `NOTION_TOKEN=*** SETTINGS_DB_ID=*** yarn start`

- Relation property `Relation-with-Name` is created to ParentDB.
- Related like `ParentDB JOIN ChildDB ON ParentDB.Name = ChildDB.Name`.

Before | After
-- | --
image|image

#### Settings2 relation execute result
Settings2 ✅ and `Run actions` or `NOTION_TOKEN=*** SETTINGS_DB_ID=*** yarn start`

- Relation property `Relation with Tags` is created to ParentDB.
- Related like `ParentDB JOIN ChildDB ON ParentDB.Tags = ChildDB.Tags`.

Before | After
-- | --
image|image

#### Settings3 relation execute result
Settings3 ✅ and `Run actions` or `NOTION_TOKEN=*** SETTINGS_DB_ID=*** yarn start`

- Relation property `Relation with Name,Tags` is created to ParentDB.
- Related like `ParentDB JOIN ChildDB ON ParentDB.Name = ChildDB.Name AND ParentDB.Tags = ChildDB.Tags`.

Before | After
-- | --
image|image