1
0
Fork 0
peertube/server/models/request-to-pod.ts

39 lines
759 B
TypeScript
Raw Normal View History

2016-12-11 15:50:51 -05:00
module.exports = function (sequelize, DataTypes) {
const RequestToPod = sequelize.define('RequestToPod', {}, {
2016-12-29 03:33:28 -05:00
indexes: [
{
fields: [ 'requestId' ]
},
{
fields: [ 'podId' ]
},
{
fields: [ 'requestId', 'podId' ],
unique: true
}
],
2016-12-11 15:50:51 -05:00
classMethods: {
removeByRequestIdsAndPod
2016-12-11 15:50:51 -05:00
}
})
return RequestToPod
}
// ---------------------------------------------------------------------------
function removeByRequestIdsAndPod (requestsIds, podId, callback) {
2017-05-15 16:22:03 -04:00
if (!callback) callback = function () { /* empty */ }
2016-12-11 15:50:51 -05:00
const query = {
where: {
requestId: {
$in: requestsIds
},
podId: podId
}
}
this.destroy(query).asCallback(callback)
}