aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/pods.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/pods.js')
-rw-r--r--server/models/pods.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/server/models/pods.js b/server/models/pods.js
index 4020a9603..6ab018c1c 100644
--- a/server/models/pods.js
+++ b/server/models/pods.js
@@ -1,11 +1,14 @@
1'use strict' 1'use strict'
2 2
3const each = require('async/each')
3const mongoose = require('mongoose') 4const mongoose = require('mongoose')
4const map = require('lodash/map') 5const map = require('lodash/map')
5const validator = require('express-validator').validator 6const validator = require('express-validator').validator
6 7
7const constants = require('../initializers/constants') 8const constants = require('../initializers/constants')
8 9
10const Video = mongoose.model('Video')
11
9// --------------------------------------------------------------------------- 12// ---------------------------------------------------------------------------
10 13
11const PodSchema = mongoose.Schema({ 14const PodSchema = mongoose.Schema({
@@ -51,6 +54,17 @@ PodSchema.pre('save', function (next) {
51 }) 54 })
52}) 55})
53 56
57PodSchema.pre('remove', function (next) {
58 // Remove the videos owned by this pod too
59 Video.listByUrl(this.url, function (err, videos) {
60 if (err) return next(err)
61
62 each(videos, function (video, callbackEach) {
63 video.remove(callbackEach)
64 }, next)
65 })
66})
67
54const Pod = mongoose.model('Pod', PodSchema) 68const Pod = mongoose.model('Pod', PodSchema)
55 69
56// ------------------------------ METHODS ------------------------------ 70// ------------------------------ METHODS ------------------------------