'use strict'
+const each = require('async/each')
const mongoose = require('mongoose')
const map = require('lodash/map')
const validator = require('express-validator').validator
const constants = require('../initializers/constants')
+const Video = mongoose.model('Video')
+
// ---------------------------------------------------------------------------
const PodSchema = mongoose.Schema({
})
})
+PodSchema.pre('remove', function (next) {
+ // Remove the videos owned by this pod too
+ Video.listByUrl(this.url, function (err, videos) {
+ if (err) return next(err)
+
+ each(videos, function (video, callbackEach) {
+ video.remove(callbackEach)
+ }, next)
+ })
+})
+
const Pod = mongoose.model('Pod', PodSchema)
// ------------------------------ METHODS ------------------------------