songs.js 869 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. const db = require('../db');
  3. module.exports = {
  4. index: (session, cb) => {
  5. db.models.song.find({}, (err, songs) => {
  6. if (err) throw err;
  7. cb(songs);
  8. });
  9. },
  10. update: (session, id, song, cb) => {
  11. //TODO Require admin/login
  12. db.models.song.findOneAndUpdate({ id }, song, { upsert: true }, (err, updatedSong) => {
  13. if (err) throw err;
  14. cb(updatedSong);
  15. });
  16. },
  17. remove: (session, id, cb) => {
  18. //TODO Require admin/login
  19. db.models.song.find({ id }).remove().exec();
  20. },
  21. add: (session, id, cb) => {
  22. //TODO Require admin/login
  23. // if (!session.logged_in) return cb({ status: 'failure', message: 'You must be logged in to add a song' });
  24. //TODO Check if video already in songs list
  25. //TODO Check if video is in queue
  26. //TODO Move video over, if it has the proper properties, and add the song to the appropriate stations
  27. }
  28. };