node.js - Querying multiple collections in MongoDB scoping issue -
I want to query two separate collections by using MongoJS (node.js mongodb wrapper) to create an array of objects I am trying to present myself with my views using EJS.
The issue I have raised is doing it with scoping I am convinced that I am providing the Type error: property can not set 'name' to undefined. < Div class = "post-text" itemprop = "text"> You need to create an area that takes the current code to This this: You are sending the feedback even before filling any name. becomes: function getTeamMembers (projectID) {var member = []; // & lt; - Instant the array of objects. I want to return the projects. Fondon ({_id: mongojs.ObjectId (projectID)}, function (error, result) / // and click on the members array var team = P. = result.team; // <- It's a (var i = 0; i & lt; team.length; i ++) one for objects The array is {members [i] = {}; member [i] .accountID = team [i] .accountID; subscriber [i] .status = team [i] .status; accounting.fundon ({_id: mongojs.ObjectId ( Team [i] .accountID)}, work (error, d) Octor) {/// error occurs in the following line: /// 'Property name can not be set for undefined member' [i] .name = doc.name;});} response.send (members) ;}); }
members [] array immediately in the right place to make it available to any child's work, But I'm still getting this error:
i , why F your
findOne () callback to be executed, ending loop is already to be long and
i = team.length .
for
(var i = 0; i
var async = require ('async'); // .... async.each (Team, Function (Team Eatm, Callback) {var Members = {Account ID: Team Item Account, Status: Team ITEM.Stats, Name: ''}; Member.Pash ( Member); FindOne ({_id: mongojs.ObjectId (member.accountID)}, function (error, doctor) {if (error) callback (error); other {member.name = doc.name; callback ();}} );}, Function (mistake) {if (response) response.send (500, err.toString ()); else response.send (members);});
Comments
Post a Comment