Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column "createdAt" does not exist" in Autentication #660

Closed
abalad opened this Issue Apr 6, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@abalad
Copy link

abalad commented Apr 6, 2018

When using Sequelize + PostGress, and when renaming the createAt and UpdatedAt fields,
when performing the authentication it returns the following error.

{
    "name": "GeneralError",
    "message": "column \"createdAt\" does not exist",
    "code": 500,
    "className": "general-error",
    "data": {},
    "errors": {}
}

UserModel

// See http://docs.sequelizejs.com/en/latest/docs/models-definition/
// for more of what you can do here.
const Sequelize = require('sequelize');
const DataTypes = Sequelize.DataTypes;

module.exports = function (app) {
  const sequelizeClient = app.get('sequelizeClient');
  const usuario = sequelizeClient.define('usuario', {

    nome: {
      type: DataTypes.STRING,
    },
    apelido: {
      type: DataTypes.STRING,
    },
    email: {
      type: DataTypes.STRING,
      allowNull: false,
      unique: true
    },
    senha: {
      type: DataTypes.STRING,
      allowNull: false
    },
    // Timestamps
    createdAt: Sequelize.DATE,
    updatedAt: Sequelize.DATE,


  }, {
   // timestamps: false,
    // I want updatedAt to actually be called updateTimestamp
    updatedAt: 'updatedat',
    createdAt: 'createdat',
    hooks: {
      beforeCount(options) {
        options.raw = true;
      }
    }
  });

  // eslint-disable-next-line no-unused-vars
  usuario.associate = function (models) {
    // Define associations here
    // See http://docs.sequelizejs.com/en/latest/docs/associations/
  };

  return usuario;
};

@abalad abalad changed the title Column \"createdAt\" does not exist" in Autentication Column "createdAt" does not exist" in Autentication Apr 6, 2018

@abalad abalad closed this Apr 6, 2018

@abalad

This comment has been minimized.

Copy link
Author

abalad commented Apr 6, 2018

It was my mistake, I just changed the model:

// Timestamps createdAt: Sequelize.DATE, updatedAt: Sequelize.DATE,

to

// Timestamps createdat: Sequelize.DATE, updatedat: Sequelize.DATE,

@Alfredo-Delgado

This comment has been minimized.

Copy link

Alfredo-Delgado commented Aug 8, 2018

In case anybody else lands here, this is documentation on how to name your timestamps our opt out of sequelize timestamps: http://docs.sequelizejs.com/manual/tutorial/models-definition.html#configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.