mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +02:00
Prepare folders structure for angular app
This commit is contained in:
parent
b2ff5e3e68
commit
b9a3e09ad5
60 changed files with 13 additions and 86 deletions
55
server/models/poolRequests.js
Normal file
55
server/models/poolRequests.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
'use strict'
|
||||
|
||||
var mongoose = require('mongoose')
|
||||
|
||||
var logger = require('../helpers/logger')
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
var poolRequestsSchema = mongoose.Schema({
|
||||
type: String,
|
||||
id: String, // Special id to find duplicates (video created we want to remove...)
|
||||
request: mongoose.Schema.Types.Mixed
|
||||
})
|
||||
var PoolRequestsDB = mongoose.model('poolRequests', poolRequestsSchema)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
var PoolRequests = {
|
||||
create: create,
|
||||
findById: findById,
|
||||
list: list,
|
||||
removeRequestById: removeRequestById,
|
||||
removeRequests: removeRequests
|
||||
}
|
||||
|
||||
function create (id, type, request, callback) {
|
||||
PoolRequestsDB.create({ id: id, type: type, request: request }, callback)
|
||||
}
|
||||
|
||||
function findById (id, callback) {
|
||||
PoolRequestsDB.findOne({ id: id }, callback)
|
||||
}
|
||||
|
||||
function list (callback) {
|
||||
PoolRequestsDB.find({}, { _id: 1, type: 1, request: 1 }, callback)
|
||||
}
|
||||
|
||||
function removeRequestById (id, callback) {
|
||||
PoolRequestsDB.remove({ id: id }, callback)
|
||||
}
|
||||
|
||||
function removeRequests (ids) {
|
||||
PoolRequestsDB.remove({ _id: { $in: ids } }, function (err) {
|
||||
if (err) {
|
||||
logger.error('Cannot remove requests from the pool requests database.', { error: err })
|
||||
return // Abort
|
||||
}
|
||||
|
||||
logger.info('Pool requests flushed.')
|
||||
})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = PoolRequests
|
Loading…
Add table
Add a link
Reference in a new issue