You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
planka_custom/server/api/helpers/map-records.js

29 lines
485 B
JavaScript

module.exports = {
sync: true,
inputs: {
records: {
type: 'ref',
custom: value => _.isArray(value),
required: true
},
attribute: {
type: 'string',
defaultsTo: 'id'
},
unique: {
type: 'boolean',
defaultsTo: false
}
},
fn: function(inputs, exits) {
let result = _.map(inputs.records, inputs.attribute);
if (inputs.unique) {
result = _.uniq(result);
}
return exits.success(result);
}
};