title: How to seed player name and score into database
body: <p>I am building an scoreboard web app with angular that posts player's names and scores.  I would like to seed data before the application runs, however I am only able to seed their name if it is listed as a string within an array like so:</p>
  
  <pre><code>var players = [
    'Bob',
    'Tom',
    'Mark'
  ];
  </code></pre>
  
  <p>I would like to seed the player's name and score using an object inside an array like so:</p>
  
  <pre><code>var players = [
    {"name": "Mary", "score": 9},
    {"name": "Barry", "score": 16},
    {"name": "Harry", "score": 12}
  ];
  </code></pre>
  
  <p>Below is my function that is posting the player's name and score of '0' instead of their score inside the object listed above.  I only want a new player to receive a score of '0'.</p>
  
  <p><strong>seed.js</strong></p>
  
  <pre><code>players.forEach(function (player, index) {
    Player.find({ 'name': player},
     function(err, players) {
      if (!err &amp;&amp; !players.length) {
        Player.create({ score: 0, name: player });
      }
    });
  });
  
  This is the model that I created in MongoDB for the player:
  </code></pre>
  
  <p><strong>player.js</strong></p>
  
  <pre><code>'use strict';
  
  var mongoose = require('mongoose');
  
  var playerSchema = new mongoose.Schema({
    name: String,
    score: Number
  });
  
  var model = mongoose.model('Player', playerSchema);
  
  module.exports = model;
  </code></pre>
  
  <p>Here is my html for the player:</p>
  
  <p><strong>player.html</strong></p>
  
  <pre><code>&lt;div class="item" ng-repeat="player in players | orderBy: 'player.score' "&gt;
    &lt;label ng-hide="editing" ng-click="editing=true"&gt;{{player.name}}&lt;/label&gt;
    &lt;input ng-show="editing" ng-blur="editing = false" class="editing-label" type="text" ng-model="player.name" ng-change="player.edited = true"/&gt;
    &lt;div class="actions"&gt;
      &lt;button ng-model="player.score" min="0" ng-click="player.score = player.score - 1" type="number" &gt;-&lt;/button&gt;
      &lt;label ng-model="player.score" placeholder="0" class="editing-label"&gt;{{player.score}}&lt;/label&gt;
      &lt;button ng-model="player.score" min="0" ng-click="player.score = player.score + 1" type="number"&gt;+&lt;/button&gt;
      &lt;a href="" ng-click="savePlayers()"&gt;Save&lt;/a&gt;
      &lt;a href="" class="delete" ng-click="deletePlayer(player, $index)"&gt;Delete&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is a picture of how my app looks currently:</p>
  
  <p><a href="https://i.stack.imgur.com/MZs76.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MZs76.png" alt="Current"></a></p>
  
  <p>Here is a picture of how I would like my app to look:</p>
  
  <p><a href="https://i.stack.imgur.com/aTHp8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aTHp8.png" alt="Desired"></a></p>
  
  <p>Any help would be greatly appreciated!</p>