Implement Channel Watching

This commit is contained in:
syuilo
2017-11-01 19:33:08 +09:00
parent 2b3937d731
commit d6b03c43eb
9 changed files with 244 additions and 27 deletions

View File

@@ -3,6 +3,7 @@
*/
import $ from 'cafy';
import Channel from '../../models/channel';
import Watching from '../../models/channel-watching';
import serialize from '../../serializers/channel';
/**
@@ -22,9 +23,17 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
created_at: new Date(),
user_id: user._id,
title: title,
index: 0
index: 0,
watching_count: 1
});
// Response
res(await serialize(channel));
// Create Watching
await Watching.insert({
created_at: new Date(),
user_id: user._id,
channel_id: channel._id
});
});