1.0.4 • Published 3 years ago

sequelize-time-no-tz-postgres-hoc v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

sequelize-time-no-tz-postgres

NPM version

Add support for TIME (without time zone) data-type for PostgreSQL in Sequelize.

Motivation

Read:

Install

npm install --save sequelize-time-no-tz-postgres

Use to define models

models/my_model.js

const withTimeNoTz = require('sequelize-time-no-tz-postgres');

module.exports = function (sequelize, SequelizeDataTypes) {
  const DataTypes = withTimeNoTz(SequelizeDataTypes);

  const MyModel = sequelize.define('myModel', {
    someTimeWithoutTzField: {
      type: DataTypes.TIME_NO_TZ
    },

    // ...
  });

  // ...

  return MyModel;
};

Use in migrations

migrations/<timestamp>-add-some-time-field-to-my-model.js

const withTimeNoTz = require('sequelize-time-no-tz-postgres');

module.exports = {
  up: function (queryInterface, SequelizeBase) {
    const Sequelize = withTimeNoTz(SequelizeBase);

    return queryInterface.addColumn('myModel', 'someTimeWithoutTzField', {
      type: Sequelize.TIME_NO_TZ
    });
  },

  // ...
};