- return AccountModel.findAndCountAll(query)
- .then(({ rows, count }) => {
- return {
- data: rows,
- total: count
+ return Promise.all([
+ AccountModel.count(),
+ AccountModel.findAll(query)
+ ]).then(([ total, data ]) => ({ total, data }))
+ }
+
+ static loadAccountIdFromVideo (videoId: number): Promise<MAccount> {
+ const query = {
+ include: [
+ {
+ attributes: [ 'id', 'accountId' ],
+ model: VideoChannelModel.unscoped(),
+ required: true,
+ include: [
+ {
+ attributes: [ 'id', 'channelId' ],
+ model: VideoModel.unscoped(),
+ where: {
+ id: videoId
+ }
+ }
+ ]