Friday 13 October 2017

How to have a number with 7 decimal always with Knex/Objection.js

I've discovered Objection.js and Knex through this subreddit and am sold on it having come from Sequelize. Thank you!I have a latitude and longitude that I want to save to my database. In mysql I would define it as such:latitude DECIMAL(11, 6),longitude DECIMAL(11, 6),In Knex I do this cause I don't see additional options in the docs to define length: table.decimal('latitude'); table.decimal('longitude'); When I save to my db the persisted object returned by promise has the entire number but in the db there are only 2 decimal numbers after the comma.At this point it's just easier to save as string?

Submitted October 13, 2017 at 02:10PM by brogramming102

No comments:

Post a Comment