diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-12-24 16:59:17 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-12-24 16:59:17 +0100 |
commit | 7920c273a204e2469416a30b752b12ccd3160102 (patch) | |
tree | 5b3d9ab9596dd5eb079a281f82b836e03eff1617 /server/models/tag.js | |
parent | 3897209f46f4c4581be2b8963bf9acc28ca5032b (diff) | |
download | PeerTube-7920c273a204e2469416a30b752b12ccd3160102.tar.gz PeerTube-7920c273a204e2469416a30b752b12ccd3160102.tar.zst PeerTube-7920c273a204e2469416a30b752b12ccd3160102.zip |
Move tags in another table
Diffstat (limited to 'server/models/tag.js')
-rw-r--r-- | server/models/tag.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/server/models/tag.js b/server/models/tag.js new file mode 100644 index 000000000..874e88842 --- /dev/null +++ b/server/models/tag.js | |||
@@ -0,0 +1,30 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | // --------------------------------------------------------------------------- | ||
4 | |||
5 | module.exports = function (sequelize, DataTypes) { | ||
6 | const Tag = sequelize.define('Tag', | ||
7 | { | ||
8 | name: { | ||
9 | type: DataTypes.STRING | ||
10 | } | ||
11 | }, | ||
12 | { | ||
13 | classMethods: { | ||
14 | associate | ||
15 | } | ||
16 | } | ||
17 | ) | ||
18 | |||
19 | return Tag | ||
20 | } | ||
21 | |||
22 | // --------------------------------------------------------------------------- | ||
23 | |||
24 | function associate (models) { | ||
25 | this.belongsToMany(models.Video, { | ||
26 | foreignKey: 'tagId', | ||
27 | through: models.VideoTag, | ||
28 | onDelete: 'cascade' | ||
29 | }) | ||
30 | } | ||