I am creating a table using Knex.JS, and the table has a column for a currency value.
For example, here is the column amount
:
knex.schema.createTable('payment', function(table) {
table.increments();
table.float('amount');
})
Currently, I am using the float
type, but I'd like to use the numeric
type. What is the equivalent of the numeric type in Knex.JS?
Thanks.
For currency decimal
is best match, so your code may look like:
knex.schema.createTable('payment', function(table) {
table.increments();
table.decimal('amount',14,2); // e.g. 14 positions, 2 for the cents
});
see http://knexjs.org/#Schema-decimal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With