sequelize-date-no-tz-postgres
v1.0.0
Published
Add support for DATE-NO-TZ data-type for PostgreSQL in Sequelize
Downloads
12,523
Maintainers
Readme
sequelize-date-no-tz-postgres
Add support for DATE (timestamp without time zone) data-type for PostgreSQL in Sequelize.
Motivation
Read:
- https://github.com/sequelize/sequelize/issues/2572
Install
npm install --save sequelize-date-no-tz-postgres
Use to define models
models/my_model.js
const withDateNoTz = require('sequelize-date-no-tz-postgres');
module.exports = function (sequelize, SequelizeDataTypes) {
const DataTypes = withDateNoTz(SequelizeDataTypes);
const MyModel = sequelize.define('myModel', {
someDateWithoutTzField: {
type: DataTypes.DATE_NO_TZ
},
// ...
});
// ...
return MyModel;
};
Use in migrations
migrations/<timestamp>-add-some-date-field-to-my-model.js
const withDateNoTz = require('sequelize-date-no-tz-postgres');
module.exports = {
up: function (queryInterface, SequelizeBase) {
const Sequelize = withDateNoTz(SequelizeBase);
return queryInterface.addColumn('myModel', 'someDateWithoutTzField', {
type: Sequelize.DATE_NO_TZ
});
},
// ...
};