This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getStories = (category, fields, sort, limit, page, callback) => { | |
//default values for these should be moved to config module | |
const f = (fields && fields !== 'all') ? fields.replace(new RegExp(',', 'g'), ' ') : (fields !== 'all') ? 'id category headline teaser author create_date' : null; | |
const s = (sort) ? sort.replace(new RegExp(',', 'g'), ' ') : '-create_date'; | |
const l = (limit) ? Number(limit) : 10; | |
const p = (page) ? Number(page) : 0; | |
//Story here is a previously create Mongoose model | |
let query = Story.find({ category: category }); |