Node-mysql2: What is the reason DATE column returns ISO8601 datetime string?

Created on 24 Feb 2017  路  2Comments  路  Source: sidorares/node-mysql2

CREATE TABLE `event` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `venue_id` int(10) unsigned NOT NULL,
  `movie_id` int(10) unsigned NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `url` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `event` (`venue_id`,`movie_id`,`date`,`time`),
  KEY `movie_id` (`movie_id`),
  CONSTRAINT `event_ibfk_4` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`id`) ON DELETE CASCADE,
  CONSTRAINT `event_ibfk_5` FOREIGN KEY (`venue_id`) REFERENCES `venue` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1487 DEFAULT CHARSET=utf8;
SELECT * FROM event

returns date as (e.g.):

2017-02-24T00:00:00.000Z
2017-02-25T00:00:00.000Z
2017-02-26T00:00:00.000Z
2017-02-27T00:00:00.000Z
2017-02-28T00:00:00.000Z
2017-03-02T00:00:00.000Z

Shouldn't it just return YYYY-MM-DD?

question

Most helpful comment

This is documented as dateStrings configuration.

https://github.com/mysqljs/mysql

All 2 comments

Sorry, I just realised that it is returning an Object, which then gets stringified.

This is documented as dateStrings configuration.

https://github.com/mysqljs/mysql

Was this page helpful?
0 / 5 - 0 ratings

Related issues

framp picture framp  路  3Comments

picbenoit picture picbenoit  路  6Comments

sidorares picture sidorares  路  7Comments

jomel picture jomel  路  8Comments

patrikx3 picture patrikx3  路  7Comments