2016-12-11 15:50:51 -05:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
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: {
|
2017-02-21 15:35:59 -05:00
|
|
|
removeByRequestIdsAndPod
|
2016-12-11 15:50:51 -05:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
return RequestToPod
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2017-02-21 15:35:59 -05:00
|
|
|
function removeByRequestIdsAndPod (requestsIds, podId, callback) {
|
2016-12-11 15:50:51 -05:00
|
|
|
if (!callback) callback = function () {}
|
|
|
|
|
|
|
|
const query = {
|
|
|
|
where: {
|
|
|
|
requestId: {
|
|
|
|
$in: requestsIds
|
|
|
|
},
|
|
|
|
podId: podId
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.destroy(query).asCallback(callback)
|
|
|
|
}
|