Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 9 populate_db.js did not link employees to a team #10

Open
kelvinnicholls opened this issue Jan 13, 2017 · 1 comment
Open

Chapter 9 populate_db.js did not link employees to a team #10

kelvinnicholls opened this issue Jan 13, 2017 · 1 comment

Comments

@kelvinnicholls
Copy link

I ran this and when I checked the employees data using mongodb the team attribute was null;

To fix this I needed change 2 functions:

  1. addTeams

if (error) {
console.error('Error: ' + error);
} else {
data.team_id = team1._id;
}

changed to

    if (error) {
        console.error('Error: ' + error);
    } else {
        team1.forEach(function (team1a) {
            data.teams.forEach(function (team) {
                if (team.name === team1a.name) {
                    team.team_id = team1a._id;
                }
            });
        });
    }
  1. updateEmployeeTeams

Employee.update({}, {
team: data.team_id
}, {

changed to

Employee.update({}, {
    team: team.team_id
}, {
@StevenJoseph19
Copy link

Thanks, Kelvin!
How did the authors let this slip past?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants