function index(req, res, next) {
	var query = req.querymen;
	let qq = req.query.q;
	let q = {};
	if (qq){
  	// convert to regex
		let keywords = _.escapeRegExp(qq);
		let patterns = [
			{ s: /[aáà]/ig, v: '[aáà]' },
			{ s: /[eéè]/ig, v: '[eéè]' },
			{ s: /[iíì]/ig, v: '[iíì]' },
			{ s: /[oóò]/ig, v: '[oóò]' },
			{ s: /[uúù]/ig, v: '[uúù]' },
		];

		_.each(patterns, p => {
			keywords = keywords.replace(p.s, p.v);
		});

		let k = new RegExp(keywords, 'i');

		q = { $or: [
				
				{ title: { $regex: k, $options: 'i' } },				
				{ area: { $regex: k, $options: 'i' } },				
			]
		};
	}

	PropuestaTaller
		.find(q)
		.count()
		.exec((err, count) => {
			if (err){
				return next(err);
			}
			req.totalItems = count;
			req.result = PropuestaTaller
							.find(q)
							.populate('owner')						
                			.populate('propuestas')
							.sort(query.cursor.sort)
							.skip(query.cursor.skip)
							.limit(query.cursor.limit)
							.select(query.cursor.select)
							.exec();
			next();
		});
}
/**
 * Get list of resources
 * restriction: 'authenticate'
 */
Get list of resources
restriction: 'authenticate'
Get list of resources restriction : ' authenticate '
function index(req, res, next) {
	var query = req.querymen;
	let qq = req.query.q;
	let q = {};
	if (qq){
		let keywords = _.escapeRegExp(qq);
		let patterns = [
			{ s: /[aáà]/ig, v: '[aáà]' },
			{ s: /[eéè]/ig, v: '[eéè]' },
			{ s: /[iíì]/ig, v: '[iíì]' },
			{ s: /[oóò]/ig, v: '[oóò]' },
			{ s: /[uúù]/ig, v: '[uúù]' },
		];
		_.each(patterns, p => {
			keywords = keywords.replace(p.s, p.v);
		});
		let k = new RegExp(keywords, 'i');
		q = { $or: [
				{ title: { $regex: k, $options: 'i' } },				
				{ area: { $regex: k, $options: 'i' } },				
			]
		};
	}
	PropuestaTaller
		.find(q)
		.count()
		.exec((err, count) => {
			if (err){
				return next(err);
			}
			req.totalItems = count;
			req.result = PropuestaTaller
							.find(q)
							.populate('owner')						
                			.populate('propuestas')
							.sort(query.cursor.sort)
							.skip(query.cursor.skip)
							.limit(query.cursor.limit)
							.select(query.cursor.select)
							.exec();
			next();
		});
}
function index ( req , res , next ) { var query = req . querymen ; let qq = req . query . q ; let q = { } ; if ( qq ) { let keywords = _ . escapeRegExp ( qq ) ; let patterns = [ { s : / [aáà]/i g ,  v ' aáà]' }, { s : / [eéè]/i g ,  v ' eéè]' }, { s : / [iíì]/i g ,  v ' iíì]' }, { s : / [oóò]/i g ,  v ' oóò]' }, { s : / [uúù]/i g ,  v ' uúù]' }, ] ; _ . each ( patterns , p => { keywords = keywords . replace ( p . s , p . v ) ; } ) ; let k = new RegExp ( keywords , 'i' ) ; q = { $or : [ { title : { $regex : k , $options : 'i' } } , { area : { $regex : k , $options : 'i' } } , ] } ; } PropuestaTaller . find ( q ) . count ( ) . exec ( ( err , count ) => { if ( err ) { return next ( err ) ; } req . totalItems = count ; req . result = PropuestaTaller . find ( q ) . populate ( 'owner' ) . populate ( 'propuestas' ) . sort ( query . cursor . sort ) . skip ( query . cursor . skip ) . limit ( query . cursor . limit ) . select ( query . cursor . select ) . exec ( ) ; next ( ) ; } ) ; }
Get list of resources
 restriction: 'authenticate'
Get list of resources restriction : ' authenticate '
// convert to regex