瀏覽代碼

Add color to category

sbkwgh 8 年之前
父節點
當前提交
69466a0051
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      models/category.js

+ 8 - 0
models/category.js

@@ -1,3 +1,5 @@
+let randomColor = require('randomcolor')
+
 module.exports = (sequelize, DataTypes) => {
 	let Category = sequelize.define('Category', {
 		name: {
@@ -12,6 +14,12 @@ module.exports = (sequelize, DataTypes) => {
 		value: {
 			type: DataTypes.STRING,
 			unique: true
+		},
+		color: {
+			type: DataTypes.STRING,
+			defaultValue () {
+				return randomColor()
+			}
 		}
 	}, {
 		classMethods: {