如何用续集声明postgresql json / jsonb字段? [英] How to declare postgresql json/jsonb field with sequel?

查看:108
本文介绍了如何用续集声明postgresql json / jsonb字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我坚持下去。在文档中找不到任何地方如何声明这样的空间数据类型,如inet和jsonb或json。

I'm stuck with that. Can't find anywhere in docs how to declare such spatial data types as inet and jsonb or json.

ruby​​ 2.4.1,续集4.47

ruby 2.4.1, sequel 4.47

带有的纯红宝石脚本需要续集

声明如

DB.create_table :requests do
  primary_key :id
  foreign_key :client_id, :clients
  foreign_key :service_id, :services
  DateTime :created_at, null: false
  DateTime :answered_at, null: false
  JsonBType :request, null: false
end


推荐答案

您可以使用来定义列的另一种方式方法-可以在此处中找到详细信息。在您的示例中,这变为:

You can use the alternative way of defining columns by using the column method - details can be found here. In your example this becomes:

DB.create_table :requests do
  primary_key :id
  foreign_key :client_id, :clients
  foreign_key :service_id, :services
  DateTime :created_at, null: false
  DateTime :answered_at, null: false
  column :request, :jsonb, null: false
end

这篇关于如何用续集声明postgresql json / jsonb字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆