aas*_*ah7 9 postgresql bookshelf.js knex.js
我正在使用Knex.JS创建一个表,该表有一个货币值列.
例如,这是列amount:
knex.schema.createTable('payment', function(table) {
table.increments();
table.float('amount');
})
Run Code Online (Sandbox Code Playgroud)
目前,我正在使用该float类型,但我想使用该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
});
Run Code Online (Sandbox Code Playgroud)
见http://knexjs.org/#Schema-decimal