KnexJS (Postgres) 中等效的数字类型是什么?

What is the numeric type equivalent in KnexJS (Postgres)?

我正在使用 Knex.JS 创建一个 table,table 有一个货币值列。

例如,这里是 amount 列:

knex.schema.createTable('payment', function(table) {
  table.increments();
  table.float('amount');
})

目前,我正在使用float类型,但我想使用numeric类型。 Knex.JS 中的 numeric 类型相当于什么?

谢谢。

货币 decimal 最匹配,因此您的代码可能如下所示:

knex.schema.createTable('payment', function(table) {
  table.increments();
  table.decimal('amount',14,2); // e.g. 14 positions, 2 for the cents
});

http://knexjs.org/#Schema-decimal