不要怂,就是干,撸起袖子干!

Commit 5ff679fe by Mick Hansen

Merge pull request #1985 from rogerc/freezeTableNameAssociations_master

Option to not pluralize associated table names (master)
2 parents a03312b7 12274ad2
...@@ -132,7 +132,7 @@ module.exports = (function() { ...@@ -132,7 +132,7 @@ module.exports = (function() {
if (this.as) { if (this.as) {
this.isAliased = true; this.isAliased = true;
} else { } else {
this.as = Utils.pluralize(this.target.name, this.target.options.language); this.as = (this.options.freezeAssociations ? this.target.tableName : Utils.pluralize(this.target.tableName, this.target.options.language));
} }
this.accessors = { this.accessors = {
......
...@@ -29,6 +29,7 @@ module.exports = (function() { ...@@ -29,6 +29,7 @@ module.exports = (function() {
classMethods: {}, classMethods: {},
validate: {}, validate: {},
freezeTableName: false, freezeTableName: false,
freezeAssociations: false,
underscored: false, underscored: false,
underscoredAll: false, underscoredAll: false,
paranoid: false, paranoid: false,
......
...@@ -342,6 +342,7 @@ module.exports = (function() { ...@@ -342,6 +342,7 @@ module.exports = (function() {
* @param {Boolean} [options.underscored=false] Converts all camelCased columns to underscored if true * @param {Boolean} [options.underscored=false] Converts all camelCased columns to underscored if true
* @param {Boolean} [options.underscoredAll=false] Converts camelCased model names to underscored tablenames if true * @param {Boolean} [options.underscoredAll=false] Converts camelCased model names to underscored tablenames if true
* @param {Boolean} [options.freezeTableName=false] If freezeTableName is true, sequelize will not try to alter the DAO name to get the table name. Otherwise, the dao name will be pluralized * @param {Boolean} [options.freezeTableName=false] If freezeTableName is true, sequelize will not try to alter the DAO name to get the table name. Otherwise, the dao name will be pluralized
* @param {Boolean} [options.freezeAssociations=false] If freezeAssociations is true, sequelize will not try to alter the DAO name to get the table name of the associated tables. Otherwise, the dao name will be pluralized
* @param {String|Boolean} [options.createdAt] Override the name of the createdAt column if a string is provided, or disable it if false. Timestamps must be true * @param {String|Boolean} [options.createdAt] Override the name of the createdAt column if a string is provided, or disable it if false. Timestamps must be true
* @param {String|Boolean} [options.updatedAt] Override the name of the updatedAt column if a string is provided, or disable it if false. Timestamps must be true * @param {String|Boolean} [options.updatedAt] Override the name of the updatedAt column if a string is provided, or disable it if false. Timestamps must be true
* @param {String|Boolean} [options.deletedAt] Override the name of the deletedAt column if a string is provided, or disable it if false. Timestamps must be true * @param {String|Boolean} [options.deletedAt] Override the name of the deletedAt column if a string is provided, or disable it if false. Timestamps must be true
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!