You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
171 lines
3.5 KiB
JavaScript
171 lines
3.5 KiB
JavaScript
const events = require('../models/events')
|
|
const rosters = require('../models/rosters')
|
|
const matches = require('../models/matches')
|
|
const streams = require('../models/streams')
|
|
const casters = require('../models/casters')
|
|
const hosts = require('../models/hosts')
|
|
|
|
const eventFns = {
|
|
getAll: async () => {
|
|
return await events.find().exec()
|
|
},
|
|
getById: async (id) => {
|
|
return await events.findById(id).exec()
|
|
},
|
|
update: async(id, data) => {
|
|
return await events.findByIdAndUpdate(id, data).exec()
|
|
},
|
|
delete: async (id) => {
|
|
return await events.findByIdAndDelete(id).exec()
|
|
},
|
|
create: async (data) => {
|
|
try {
|
|
const ev = new events(data)
|
|
ev.save((err) => {
|
|
if (err)
|
|
throw err;
|
|
})
|
|
} catch (e) {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
const rosterFns = {
|
|
getAll: async () => {
|
|
return await rosters.find().exec()
|
|
},
|
|
getById: async (id) => {
|
|
return await rosters.findById(id).exec()
|
|
},
|
|
update: async(id, data) => {
|
|
return await rosters.findByIdAndUpdate(id, data).exec()
|
|
},
|
|
delete: async (id) => {
|
|
return await rosters.findByIdAndDelete(id).exec()
|
|
},
|
|
create: async (data) => {
|
|
try {
|
|
const ev = new rosters(data)
|
|
ev.save((err) => {
|
|
if (err)
|
|
throw err;
|
|
})
|
|
} catch (e) {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
const matchFns = {
|
|
getAll: async () => {
|
|
return await matches.find().exec()
|
|
},
|
|
getById: async (id) => {
|
|
return await matches.findById(id).exec()
|
|
},
|
|
update: async(id, data) => {
|
|
return await matches.findByIdAndUpdate(id, data).exec()
|
|
},
|
|
delete: async (id) => {
|
|
return await matches.findByIdAndDelete(id).exec()
|
|
},
|
|
create: async (data) => {
|
|
try {
|
|
const ev = new matches(data)
|
|
ev.save((err) => {
|
|
if (err)
|
|
throw err;
|
|
})
|
|
} catch (e) {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
const streamFns = {
|
|
getAll: async () => {
|
|
return await streams.find().exec()
|
|
},
|
|
getById: async (id) => {
|
|
return await streams.findById(id).exec()
|
|
},
|
|
update: async(id, data) => {
|
|
return await streams.findByIdAndUpdate(id, data).exec()
|
|
},
|
|
delete: async (id) => {
|
|
return await streams.findByIdAndDelete(id).exec()
|
|
},
|
|
create: async (data) => {
|
|
try {
|
|
const ev = new streams(data)
|
|
ev.save((err) => {
|
|
if (err)
|
|
throw err;
|
|
})
|
|
} catch (e) {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
const casterFns = {
|
|
getAll: async () => {
|
|
return await casters.find().exec()
|
|
},
|
|
getById: async (id) => {
|
|
return await casters.findById(id).exec()
|
|
},
|
|
update: async(id, data) => {
|
|
return await casters.findByIdAndUpdate(id, data).exec()
|
|
},
|
|
delete: async (id) => {
|
|
return await casters.findByIdAndDelete(id).exec()
|
|
},
|
|
create: async (data) => {
|
|
try {
|
|
const ev = new casters(data)
|
|
ev.save((err) => {
|
|
if (err)
|
|
throw err;
|
|
})
|
|
} catch (e) {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
const hostFns = {
|
|
getAll: async () => {
|
|
return await hosts.find().exec()
|
|
},
|
|
getById: async (id) => {
|
|
return await hosts.findById(id).exec()
|
|
},
|
|
update: async(id, data) => {
|
|
return await hosts.findByIdAndUpdate(id, data).exec()
|
|
},
|
|
delete: async (id) => {
|
|
return await hosts.findByIdAndDelete(id).exec()
|
|
},
|
|
create: async (data) => {
|
|
try {
|
|
const ev = new hosts(data)
|
|
ev.save((err) => {
|
|
if (err)
|
|
throw err;
|
|
})
|
|
} catch (e) {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
'events': eventFns,
|
|
'rosters': rosterFns,
|
|
'matches': matchFns,
|
|
'streams': streamFns,
|
|
'casters': casterFns,
|
|
'hosts': hostFns,
|
|
} |