Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/HelloEvenZhang/notion-model
A ruby gem that allows you to read, write, and update Notion databases and pages like ActiveModel.
https://github.com/HelloEvenZhang/notion-model
notion ruby ruby-on-rails
Last synced: about 1 month ago
JSON representation
A ruby gem that allows you to read, write, and update Notion databases and pages like ActiveModel.
- Host: GitHub
- URL: https://github.com/HelloEvenZhang/notion-model
- Owner: HelloEvenZhang
- License: mit
- Created: 2023-03-01T04:07:44.000Z (almost 2 years ago)
- Default Branch: release
- Last Pushed: 2023-04-26T09:46:46.000Z (over 1 year ago)
- Last Synced: 2024-10-29T14:18:14.507Z (about 2 months ago)
- Topics: notion, ruby, ruby-on-rails
- Language: Ruby
- Homepage:
- Size: 55.7 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Notion::Rb
一个能让你像ActiveModel一样增删改查Notion中的Databases和Pages的RubyGem
## 安装
依赖:
- Ruby >= 2.6安装命令:
```bash
gem install notion-rb
```或在Gemfile中增加
```ruby
gem 'notion-rb'
```然后执行
```bash
bundle install
```## 使用
```ruby
# 先做好必要配置
Notion.config.token = 'YOUR_NOTION_TOKEN'# 或者
Notion.configure do |config|
config.token = "YOUR_NOTION_TOKEN"
end# 参考ActiveRecord处理数据的方法,以面向对象的方式操作数据
database = Notion::Database.find(your_database_id)# 由于不同Database下的Page都可能有不同的属性
# 因此每个Page实例中的属性在获得pages时动态生成
pages = database.pages# 把提供的选项转换为等价的JSON Query结构体
# 触发Http请求并从Response中检索对应的结果
# 为每个查询结果实例化对应的模型对象
some_pages = pages.where(options)```