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

Update mysql.js #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update mysql.js #147

wants to merge 1 commit into from

Conversation

hfwittmann
Copy link

For the model given below the index for "testcolumn" is not created when using the current master. This is due to a resulting conflict in l 249 mysql, because the unique property alreadys exists in the table); This is avoided by the proposed change.

/**

  • Define User Model

  • @param {Object} schema

  • @return {Object}
    **/
    module.exports = function (schema) {

    const user = schema.define('user', {
    active : { type : schema.Number },
    username : { type : schema.String, unique : true },
    email : { type : schema.String, unique :true },
    password : { type : schema.String},
    note : { type : schema.Text },
    testcolumn : { type : schema.Date, index:true }
    },{

    // primaryKeys:["email"] // fails
    

    });

    user.validatesPresenceOf('username', 'email', 'password');

    // additional methods and validation here

    return user;
    };

For the following model the index for "testcolumn" is not created for the current master (due to a resulting conflict in l 249 mysql, because the unique property already exists in the table); This is avoided by the proposed change.

/**
 *  Define User Model
 *  @param {Object} schema
 *  @return {Object}
 **/
module.exports = function (schema) {

    const user = schema.define('user', {
           active : { type : schema.Number },
           username : { type : schema.String, unique : true },
           email : { type : schema.String, unique :true },
           password : { type : schema.String},
           note : { type : schema.Text },
           testcolumn : { type : schema.Date, index:true  }
    },{

        // primaryKeys:["email"] // fails
    });


    user.validatesPresenceOf('username', 'email', 'password');

    // additional methods and validation here

    return user;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant