1
0
Fork 0
peertube/server/models/request-to-pod.js
2017-01-04 21:05:13 +01:00

42 lines
814 B
JavaScript

'use strict'
// ---------------------------------------------------------------------------
module.exports = function (sequelize, DataTypes) {
const RequestToPod = sequelize.define('RequestToPod', {}, {
indexes: [
{
fields: [ 'requestId' ]
},
{
fields: [ 'podId' ]
},
{
fields: [ 'requestId', 'podId' ],
unique: true
}
],
classMethods: {
removePodOf
}
})
return RequestToPod
}
// ---------------------------------------------------------------------------
function removePodOf (requestsIds, podId, callback) {
if (!callback) callback = function () {}
const query = {
where: {
requestId: {
$in: requestsIds
},
podId: podId
}
}
this.destroy(query).asCallback(callback)
}