[英]Datatypes of Knex that I can use with PostgreSQL
To clarify my question, at the moment I am creating a Migration file for a table that will be in my database.为了澄清我的问题,目前我正在为将在我的数据库中的表创建迁移文件。 But I cannot find all the datatypes I can use, I wonder where could I find them since PostgreSQL provides a lot of datatypes.
但是我找不到我可以使用的所有数据类型,我想知道在哪里可以找到它们,因为 PostgreSQL 提供了很多数据类型。 And, I wonder if I am able to use some of them.
而且,我想知道我是否能够使用其中的一些。
My migration file:我的迁移文件:
exports.up = function(knex) {
return knex.schema.createTable('organizations', function (table) {
table.increments('id').unsigned().primary()
table.dateTime('registeredAt').notNull()
})
}
As seen above, I am able to use datetime
but could I use, for example, cdr
which is for IP addresses in v4 or v6.如上所示,我可以使用
datetime
但我可以使用例如cdr
,它用于 v4 或 v6 中的 IP 地址。 And also, if exists, a documentation of what maps to what would be very useful.而且,如果存在,什么映射到什么的文档将非常有用。
Also, if you are able to, a definite answer with an array of IP addresses column would be very kind of you.此外,如果您可以,使用一组 IP 地址列的明确答案对您来说会非常友好。
Knex has a specificType method that accepts any valid DB column type. Knex 有一个specificType方法,可以接受任何有效的 DB 列类型。
exports.up = function(knex) {
return knex.schema.createTable('organizations', function (table) {
table.specificType('columnName', 'tinyInt');
})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.