Express REST API router and Mongoose schema design Express REST API router and Mongoose schema design mongoose mongoose

Express REST API router and Mongoose schema design


For your first question, please visit my answer here:

embedding vs referencing

For the second I would create a separate router file following the separation of concerns pattern and concerning endpoint I would choose router.get('/:userId/:documentId'), because if I unterstand you correctly, every document belongs to an user.