diff options
Diffstat (limited to 'server/models/video/author.ts')
-rw-r--r-- | server/models/video/author.ts | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/server/models/video/author.ts b/server/models/video/author.ts index 4a115e328..3222c4834 100644 --- a/server/models/video/author.ts +++ b/server/models/video/author.ts | |||
@@ -4,7 +4,6 @@ import { isUserUsernameValid } from '../../helpers' | |||
4 | 4 | ||
5 | import { addMethodsToModel } from '../utils' | 5 | import { addMethodsToModel } from '../utils' |
6 | import { | 6 | import { |
7 | AuthorClass, | ||
8 | AuthorInstance, | 7 | AuthorInstance, |
9 | AuthorAttributes, | 8 | AuthorAttributes, |
10 | 9 | ||
@@ -74,30 +73,18 @@ function associate (models) { | |||
74 | }) | 73 | }) |
75 | } | 74 | } |
76 | 75 | ||
77 | findOrCreateAuthor = function ( | 76 | findOrCreateAuthor = function (name: string, podId: number, userId: number, transaction: Sequelize.Transaction) { |
78 | name: string, | ||
79 | podId: number, | ||
80 | userId: number, | ||
81 | transaction: Sequelize.Transaction, | ||
82 | callback: AuthorMethods.FindOrCreateAuthorCallback | ||
83 | ) { | ||
84 | const author = { | 77 | const author = { |
85 | name, | 78 | name, |
86 | podId, | 79 | podId, |
87 | userId | 80 | userId |
88 | } | 81 | } |
89 | 82 | ||
90 | const query: any = { | 83 | const query: Sequelize.FindOrInitializeOptions<AuthorAttributes> = { |
91 | where: author, | 84 | where: author, |
92 | defaults: author | 85 | defaults: author, |
86 | transaction | ||
93 | } | 87 | } |
94 | 88 | ||
95 | if (transaction !== null) query.transaction = transaction | 89 | return Author.findOrCreate(query).then(([ authorInstance ]) => authorInstance) |
96 | |||
97 | Author.findOrCreate(query).asCallback(function (err, result) { | ||
98 | if (err) return callback(err) | ||
99 | |||
100 | // [ instance, wasCreated ] | ||
101 | return callback(null, result[0]) | ||
102 | }) | ||
103 | } | 90 | } |