sequelize-date-no-tz-postgres

Add support for DATE-NO-TZ data-type for PostgreSQL in Sequelize

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
sequelize-date-no-tz-postgres
1.0.06 years ago6 years agoMinified + gzip package size for sequelize-date-no-tz-postgres in KB

Readme

sequelize-date-no-tz-postgres
NPM version
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
    });
  },

  // ...
};