Skip to content

A ruby gem that allows you to read, write, and update Notion databases and pages like ActiveModel.

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

HelloEvenZhang/notion-model

Notion::Rb

一个能让你像ActiveModel一样增删改查Notion中的Databases和Pages的RubyGem

安装

依赖:

  • Ruby >= 2.6

安装命令:

gem install notion-rb

或在Gemfile中增加

gem 'notion-rb'

然后执行

bundle install

使用

# 先做好必要配置
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)

About

A ruby gem that allows you to read, write, and update Notion databases and pages like ActiveModel.

Topics

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Code of conduct

Stars

Watchers

Forks

Packages

No packages published