V
V
Vadim2014-11-10 22:03:54
Design patterns
Vadim, 2014-11-10 22:03:54

Is it advisable to use the Repository pattern when developing with nodejs?

If, when implementing Mongoose, some of the properties of the pattern are transferred to the database models?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2014-11-11
@k12th

Are you talking about this?

// define an Actor model with this mongoose instance
mongoose.model('Actor', new Schema({ name: String }));

// create a new connection
var conn = mongoose.createConnection(..);

// retrieve the Actor model
var Actor = conn.model('Actor'); // repository??

Hammer, he needs it for the population of nested documents in the main.
That Mongoose takes on too much shouldn't affect your architecture. Maybe tomorrow you will switch to a native driver or even change the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question