سؤال

I try to find a good directory structure for my nodejs/express/mongoDB application.

Currently I use the native-mongodb driver which feels nice and fast but is limited when a proper structure should be defined... when MVC is the express/node way to go defining proper db models is not that easy.

Although mongoose and its concept of schemas would make the actual design of models easy but I am not that big of a fan of another layer on top of my stack... it feels kinda bloated to me.

I looked for an alternative and found mongoskin which is a thin wrapper on top of the native-driver but adds some features to support MVC-ish patterns.

In general I found this to be a common problem for other people too. I appreciate the idea presented in the link: https://stackoverflow.com/a/8428281/1055685

Nevertheless the query inside the model directory is not really MVC-like (as mentioned in the comments...) - I do not like it...

The MVC demos in express are not that helpful... did you find some inspiration there?

Which pattern do you recommend to follow (if MVC is recommended models are the real problem)? Do you recommend mongoskin in general?

هل كانت مفيدة؟

المحلول

I would suggest looking at either LocomotiveJS or RailwayJS

LocomotiveJS is more "lightweight" and there is a great boilerplate available to get you started.

RailwayJS contains more "generators" to make it more rails-like however.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top