Skip to content

Instantly share code, notes, and snippets.

@pantchox
Created October 2, 2017 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pantchox/be8023b6d3850de0dae48790e63abd4f to your computer and use it in GitHub Desktop.
Save pantchox/be8023b6d3850de0dae48790e63abd4f to your computer and use it in GitHub Desktop.
// i want all the index - /api/bookLists
// BookLists is the model import
export const index = ({ user }, res, next) =>
BookLists.find({ user: user.id})
.populate('user')
.populate('books')
.then((bookLists) => bookLists.map((bookLists) => bookLists.view(true))) // this is a call to the Model method of view
.then(success(res))
.catch(next)
// the '/' route is fine its a inner level routing being handled by a router, it gets there thats the point.
router.get('/',
token({ required: true }),
query(),
index)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment