我正在使用 Knex.JS 创建一个表, 表格中有一列表示货币值。
例如,这里是 amount
列:
knex.schema.createTable('payment', function(table) {
table.increments();
table.float('amount');
})
目前,我正在使用float
类型,但我想使用numeric
类型。 numeric 的等价物是什么输入 Knex.JS?
谢谢。
最佳答案
对于货币 decimal
是最匹配的,因此您的代码可能如下所示:
knex.schema.createTable('payment', function(table) {
table.increments();
table.decimal('amount',14,2); // e.g. 14 positions, 2 for the cents
});
关于postgresql - KnexJS (Postgres) 中等效的数字类型是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37059040/