Use remote id as identifier
*/
-const each = require('async/each')
const map = require('lodash/map')
const mongoose = require('mongoose')
const readline = require('readline')
const urls = map(pods, 'url')
logger.info('Saying goodbye to: ' + urls.join(', '))
- friends.quitFriends(function () {
- setVideosRemoteId(callback)
+ setVideosRemoteId(function () {
+ friends.quitFriends(callback)
})
})
})
}
function setVideosRemoteId (callback) {
- Video.find({}, function (err, videos) {
- if (err) return callback(err)
+ Video.update({ filename: { $ne: null } }, { remoteId: null }, function (err) {
+ if (err) throw err
- each(videos, function (video, callbackEach) {
- video.remoteId = null
- video.save(callbackEach)
- }, callback)
+ Video.update({ filename: null }, { remoteId: mongoose.Types.ObjectId() }, callback)
})
}