Fix loading deleted users on actions fetch. Closes #62

pull/67/head
Maksim Eltyshev 5 years ago
parent a3adddac6f
commit 3cdb614b57

@ -42,7 +42,7 @@ module.exports = {
const actions = await sails.helpers.getActionsForCard(inputs.cardId, inputs.beforeId);
const userIds = sails.helpers.mapRecords(actions, 'userId', true);
const users = await sails.helpers.getUsers(userIds);
const users = await sails.helpers.getUsers(userIds, true);
return exits.success({
items: actions,

@ -4,12 +4,14 @@ module.exports = {
type: 'json',
custom: (value) => _.isArray(value) || _.isPlainObject(value),
},
withDeleted: {
type: 'boolean',
defaultsTo: false,
},
},
async fn(inputs, exits) {
const criteria = {
deletedAt: null,
};
const criteria = {};
if (_.isArray(inputs.criteria)) {
criteria.id = inputs.criteria;
@ -17,6 +19,10 @@ module.exports = {
Object.assign(criteria, inputs.criteria);
}
if (!inputs.withDeleted) {
criteria.deletedAt = null;
}
const users = await User.find(criteria).sort('id');
return exits.success(users);

Loading…
Cancel
Save