2019-08-31 04:07:25 +05:00
|
|
|
module.exports = {
|
|
|
|
inputs: {
|
|
|
|
id: {
|
|
|
|
type: 'json',
|
2019-11-05 18:01:42 +05:00
|
|
|
custom: (value) => _.isString(value) || _.isArray(value),
|
|
|
|
required: true,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
withProjectMemberships: {
|
|
|
|
type: 'boolean',
|
2019-11-05 18:01:42 +05:00
|
|
|
defaultsTo: false,
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
2019-11-05 18:01:42 +05:00
|
|
|
async fn(inputs, exits) {
|
|
|
|
const projectMemberships = await sails.helpers.getMembershipsForProject(inputs.id);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2019-11-05 18:01:42 +05:00
|
|
|
const userIds = sails.helpers.mapRecords(projectMemberships, 'userId', _.isArray(inputs.id));
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
return exits.success(
|
|
|
|
inputs.withProjectMemberships
|
|
|
|
? {
|
|
|
|
userIds,
|
2019-11-05 18:01:42 +05:00
|
|
|
projectMemberships,
|
2019-08-31 04:07:25 +05:00
|
|
|
}
|
2019-11-05 18:01:42 +05:00
|
|
|
: userIds,
|
2019-08-31 04:07:25 +05:00
|
|
|
);
|
2019-11-05 18:01:42 +05:00
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|