diff options
author | Yukai Huang | 2017-03-13 21:32:50 +0800 |
---|---|---|
committer | Yukai Huang | 2017-03-13 21:32:50 +0800 |
commit | 93e41f3a40394f061ca81c8ce119c85611173621 (patch) | |
tree | 20a81f7e77263e05b3d28304f72f4f224d931b0e /lib/models/author.js | |
parent | 9b513f619fe74a579fadd807f86bd38f1049c56b (diff) | |
parent | edb1b4aa0a72ac8b0215211c9dbc54156c3ff91f (diff) |
Merge branch 'master' into cm-refactor
Diffstat (limited to 'lib/models/author.js')
-rw-r--r-- | lib/models/author.js | 74 |
1 files changed, 34 insertions, 40 deletions
diff --git a/lib/models/author.js b/lib/models/author.js index 0b0f149d..5e39c347 100644 --- a/lib/models/author.js +++ b/lib/models/author.js @@ -1,43 +1,37 @@ -"use strict"; - // external modules -var Sequelize = require("sequelize"); - -// core -var logger = require("../logger.js"); +var Sequelize = require('sequelize') module.exports = function (sequelize, DataTypes) { - var Author = sequelize.define("Author", { - id: { - type: Sequelize.INTEGER, - primaryKey: true, - autoIncrement: true - }, - color: { - type: DataTypes.STRING - } - }, { - indexes: [ - { - unique: true, - fields: ['noteId', 'userId'] - } - ], - classMethods: { - associate: function (models) { - Author.belongsTo(models.Note, { - foreignKey: "noteId", - as: "note", - constraints: false - }); - Author.belongsTo(models.User, { - foreignKey: "userId", - as: "user", - constraints: false - }); - } - } - }); - - return Author; -};
\ No newline at end of file + var Author = sequelize.define('Author', { + id: { + type: Sequelize.INTEGER, + primaryKey: true, + autoIncrement: true + }, + color: { + type: DataTypes.STRING + } + }, { + indexes: [ + { + unique: true, + fields: ['noteId', 'userId'] + } + ], + classMethods: { + associate: function (models) { + Author.belongsTo(models.Note, { + foreignKey: 'noteId', + as: 'note', + constraints: false + }) + Author.belongsTo(models.User, { + foreignKey: 'userId', + as: 'user', + constraints: false + }) + } + } + }) + return Author +} |