add option to get populated data for streams

main
Ayush Mukherjee 4 years ago
parent 1bf671fdfe
commit c4c1c86249

@ -14,7 +14,9 @@ const events = [
'delete',
];
const channelEvents = [];
const channelEvents = [
'streams:full',
];
channels.forEach((c) => {
events.forEach((e) => {

@ -86,10 +86,12 @@ const matchFns = {
const streamFns = {
getAll: async () => {
return await streams.find().exec()
// return await streams.find().populate('event').populate({
// path: 'matches',
// populate: [{ path: 'orange' }, { path: 'blue' }],
// }).populate('casters').populate('hosts').exec()
},
getAllPop: async () => {
return await streams.find().populate('event').populate({
path: 'matches',
populate: [{ path: 'orange' }, { path: 'blue' }],
}).populate('casters').populate('hosts').exec()
},
getById: async (id) => {
return await streams.findById(id).populate('event').populate('matches').populate('casters').populate('hosts').exec()

@ -33,6 +33,9 @@ const handleMsg = async (msg, id) => {
event: `${channel}:read`,
data: await crud[channel].getAll(),
}
if (channel === 'streams' && d.subscribe === 'streams:full') {
dm.data = await crud[channel].getAllPop()
}
connections[id].connection.send(JSON.stringify(dm))
} else if (d.hasOwnProperty('event') && channelEvents.indexOf(d.event) !== -1) {
const ev = d.event.split(':')

Loading…
Cancel
Save