mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Added getLabelRelations to Member Model
refs https://github.com/TryGhost/Team/issues/946 In order to bulk remove relations between members and labels we need a way to get hold of all of the existing relations between a label and a set of members.
This commit is contained in:
parent
2f33292600
commit
1835c22f3b
@ -328,6 +328,19 @@ const Member = ghostBookshelf.Model.extend({
|
||||
});
|
||||
}
|
||||
return ghostBookshelf.Model.destroy.call(this, unfilteredOptions);
|
||||
},
|
||||
|
||||
getLabelRelations(data, unfilteredOptions = {}) {
|
||||
const query = ghostBookshelf.knex('members_labels')
|
||||
.select('id')
|
||||
.where('label_id', data.labelId)
|
||||
.whereIn('member_id', data.memberIds);
|
||||
|
||||
if (unfilteredOptions.transacting) {
|
||||
query.transacting(unfilteredOptions.transacting);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user