Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Trying to make database fields to be underscored #20

Open
wants to merge 2 commits into
base: db_changes
Choose a base branch
from

Conversation

mahnunchik
Copy link
Contributor

Trying to make database fields to be underscored. Sequelize updated to 2.0.0-rc2

  • Unit tests pass
  • Controllers tests fails

Following construction allowed me to use createdAt and updatedAt without overwriting their default:

getterMethods: {
    createdAt: function() {
        return this.getDataValue('created_at');
    },
    updatedAt: function() {
       return this.getDataValue('updated_at');     
   }
}

In additional if we use Sequelize 2.0 maybe it make sence to use migrations from sequelize: http://sequelizejs.com/docs/latest/migrations

…o 2.0.0-rc2, Unit tests pass, Controllers tests fails
@mahnunchik
Copy link
Contributor Author

Warning: only unit tests are enabled in this PR

@@ -39,10 +39,10 @@ module.exports = function(config) {
db[model.name] = model;
});

Object.keys(db).forEach(function(modelName) {
/*Object.keys(db).forEach(function(modelName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the thought behind this change? Does this not init the variable until we need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it is a mistake. It seems I committed wrong changes of this file.
This should be without comment and without options path:

Object.keys(db).forEach(function(modelName) {
    if (db[modelName].hasOwnProperty('associate')) {
      db[modelName].associate(db);
    }
  });

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants