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

I am creating a table using Knex.JS , and the table has a column for the currency value.

For example, here is a column amount:

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

I am currently using a type float, but I would like to use a type numeric. What is equivalent to the numeric type in Knex.JS?

Thank.

+4
source share
1 answer

decimalBest suited for currency , so your code might look like this:

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

+4
source

All Articles