{createdAt: new Date()} in Model.findOrCreate() throws a Moment.js deprecation warning
See original GitHub issuesequelize.transaction((t) => {
const query = {
createdAt: {
$gt: new Date(new Date() - 24 * 60 * 60 * 1000)
}
};
const values = {
createdAt: new Date()
};
return Model.findOrCreate({ where: query, defaults: values, transaction: t })
})
/**
Deprecation warning: value provided is not in a recognized ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: Fri Sep 08 2017 19:10:22 GMT+0200 (ora legale Europa occidentale), _f: undefined, _strict: undefined, _locale: [object Object]
Error
at Function.createFromInputFallback (c:\Users\PC\Desktop\project\node_modules\moment\moment.js:318:94)
at configFromString (c:\Users\PC\Desktop\project\node_modules\moment\moment.js:2080:15)
at configFromInput (c:\Users\PC\Desktop\project\node_modules\moment\moment.js:2444:9)
at prepareConfig (c:\Users\PC\Desktop\project\node_modules\moment\moment.js:2427:9)
at createFromConfig (c:\Users\PC\Desktop\project\node_modules\moment\moment.js:2394:40)
at createLocalOrUTC (c:\Users\PC\Desktop\project\node_modules\moment\moment.js:2481:12)
at createLocal (c:\Users\PC\Desktop\project\node_modules\moment\moment.js:2485:12)
at hooks (c:\Users\PC\Desktop\project\node_modules\moment\moment.js:16:25)
at ABSTRACT._applyTimezone (c:\Users\PC\Desktop\project\node_modules\sequelize\lib\data-types.js:323:14)
at DATE._stringify (c:\Users\PC\Desktop\project\node_modules\sequelize\lib\dialects\mysql\data-types.js:76:37)
at DATE.stringify (c:\Users\PC\Desktop\project\node_modules\sequelize\lib\data-types.js:32:17)
at Object.escape (c:\Users\PC\Desktop\project\node_modules\sequelize\lib\dialects\abstract\query-generator.js:906:32)
at Object.whereItemQuery (c:\Users\PC\Desktop\project\node_modules\sequelize\lib\dialects\abstract\query-generator.js:2306:22)
at _.forOwn (c:\Users\PC\Desktop\project\node_modules\sequelize\lib\dialects\abstract\query-generator.js:1937:25)
at c:\Users\PC\Desktop\project\node_modules\lodash\lodash.js:4944:15
at baseForOwn (c:\Users\PC\Desktop\project\node_modules\lodash\lodash.js:3001:24)
at Function.forOwn (c:\Users\PC\Desktop\project\node_modules\lodash\lodash.js:13002:24)
at Object.whereItemsQuery (c:\Users\PC\Desktop\project\node_modules\sequelize\lib\dialects\abstract\query-generator.js:1936:9)
at Object.getWhereConditions (c:\Users\PC\Desktop\project\node_modules\sequelize\lib\dialects\abstract\query-generator.js:2377:19)
at Object.selectQuery (c:\Users\PC\Desktop\project\node_modules\sequelize\lib\dialects\abstract\query-generator.js:1123:28)
at QueryInterface.select (c:\Users\PC\Desktop\project\node_modules\sequelize\lib\query-interface.js:672:27)
at Promise.try.then.then.then (c:\Users\PC\Desktop\project\node_modules\sequelize\lib\model.js:1540:34)
*/
What do you expect to happen?
Should not throw a warning when using {createdAt: new Date()}
PS: I tried even with new Date().toISOString()
, same warning
What is actually happening?
A deprecation warning raises, even if the query still works
Dialect: mysql Database version: 5.7 Sequelize version: 4.8.2
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
“Deprecation warning: moment construction falls back to js ...
The date construction in moment internally uses the new Date() in the ... a moment object with date not in these formats, the...
Read more >Deprecation warning: moment construction falls back to js Date.
I have been using this add-on for a while now, but have been getting Deprecation warning messages, (though pages seem to work ok)...
Read more >Docs - Moment.js
The Date object internally represents a Unix timestamp with millisecond precision. It offers functions that will convert to and from the system's local...
Read more >date format in sequelize when get Code Example
model.findAll({ attributes: [ 'id', [sequelize.fn('date_format', sequelize.col('date_col'), '%Y-%m-%d'), 'date_col_formed'] ]}) .then(function(result) ...
Read more >wwwroot/js/moment.js - HeuristicLab
178, this._d = new Date(config._d != null ? config._d.getTime() : NaN);. 179, // Prevent infinite loop in case updateOffset creates new moment.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s still a problem
Any updates on this?