samedi 4 avril 2015

References in MongoDB / Mongoose / nodejs


Vote count:

0




I want to get references in mongoDB using nodejs/mongoose.


In the documentation I read that there are two options: Manual References or DBRefs.


Since they state its recommended to use Manual References, I decided to set up a schema in the following way:



var schema = new mongoose.Schema({
name : String,
reference : mongoose.Schema.ObjectId
});



  1. Question: If I retrieve an array of these objects from my collection, how do I resolve the references in a good practice way?


My Idea was to use Nimble and parallelize the necessary requests. I wanted to do something like



flow.parallel(functions, function() {
return actionList;
});


where I dynamically fill an array of functions



var functions = []


which I pass to nimble. (kind of this SO-question: Javascript Array of Functions)



  1. Question: Is that practical? The array of functions-thing seems kind of not really the way to go to me. But I dont see any alternative, since nimble needs to be called with a static number of functions.



asked just now







References in MongoDB / Mongoose / nodejs

Aucun commentaire:

Enregistrer un commentaire