PeerTube/server/models/request-to-pod.js

43 lines
840 B
JavaScript
Raw Normal View History

2016-12-11 14:50:51 -06:00
'use strict'
// ---------------------------------------------------------------------------
module.exports = function (sequelize, DataTypes) {
const RequestToPod = sequelize.define('RequestToPod', {}, {
2016-12-29 02:33:28 -06:00
indexes: [
{
fields: [ 'requestId' ]
},
{
fields: [ 'podId' ]
},
{
fields: [ 'requestId', 'podId' ],
unique: true
}
],
2016-12-11 14:50:51 -06:00
classMethods: {
removeByRequestIdsAndPod
2016-12-11 14:50:51 -06:00
}
})
return RequestToPod
}
// ---------------------------------------------------------------------------
function removeByRequestIdsAndPod (requestsIds, podId, callback) {
2016-12-11 14:50:51 -06:00
if (!callback) callback = function () {}
const query = {
where: {
requestId: {
$in: requestsIds
},
podId: podId
}
}
this.destroy(query).asCallback(callback)
}