app.get('/api/slugs', function(req, res) { pg('locator_map') .then(function(rows) { var rows = parse_data(rows); var slugs = _.pluck(rows, 'slug'); res.json(slugs); }) .catch(function(error) { res.json({error: error}); }); });
/** * List resources in the container. * @param {String} container container name * @return {Promise} Promise of the action */ var _listContainer = function (container) { return nodefn.call(client.list, {prefix: container}) .then(function (data) { return when.resolve(_.pluck(data.contents, 'key')) }, function (err) { logger.error('Error while listing data from S3 container: %s', container, err) return when.reject(err) }) }
/** * Clean container by removing all entries no present in the resource list. * @param {String} container Container name * @param {Object[]} resources Resource list * @retrun {Promise} Promise of the action */ var cleanContainer = function (container, resources) { var keys = _.pluck(resources, 'key') // TODO remove zero length files // List directory content... logger.debug('Cleanup S3 container: %s', container) return _listContainer(container) .then(function (entries) { // Get delta between directory content and key list var delta = _.difference(entries, keys) return when.map(delta, function (entry) { // Remove files delta. logger.debug('Removing unused resource: %s ...', entry) return remove(container, entry) }) }) }
included = _.pluck(docs, '_id'); next(); }); form.access = form.access || []; let type = _.pluck(form.access, 'type'); let foundReadAll = false; if (type.length === _.uniq(type).length) { let type = _.pluck(form.submissionAccess, 'type'); if (type.length > _.uniq(type).length) { form.submissionAccess = [];