title: How to update an existing database object depending on what data is passed
body: <p>In my react web app, I have an object saved in database which holds a time and up to 4 players.</p>
  <p>In my app, once all people entering an event have entered, admin click a button to randomly order the list of entrants, and then those entrants will be put into groups depending on the order of the random list and also how many people there can be per start time. So for example, if there are 12 entrants and max 3 per start time, they would be put into 4 groups of 3, if there were max 4 per start time it would be 3 groups of 4.</p>
  <p>I have the code that creates the random list and displays the users in the random order.</p>
  <p>Admin will create a start time which is saved in the database.</p>
  <p>I have the method which retrieves all start times for a specific event.</p>
  <p>Now I currently have it set up so that you can manually input the users into each start time and this will update the database with the users for that start time.</p>
  <p>I want to be able to update the database automatically with the users when I run the random list generator.</p>
  <p>so for example, 2 start times 09:00 and 09:30 and 8 users with 4 per start time.</p>
  <p>once the random list is generated</p>
  <pre><code>P3
  P7
  P8
  P1
  P2
  P6
  P5
  </code></pre>
  <p>I want P3,7,8 and 1 to be put in the 09:00 start time and the other 4 in the 09:30 start time.</p>
  <p>So far, I have the following</p>
  <pre><code>        let players = playerPerTee;
          getTeesheet();
          teeTimes.map((teetime =&gt; 
            console.log(teetime.id)
            ))
  </code></pre>
  <p>the <code>getTeesheet()</code> gets the current event start sheets for this event from the database. Then If I map through each one I can get the id which I will need to update the object in the database.
  I now need to get the value for the number of people per start time (<code>players</code>) then get the first teesheet and add the players from <code>randomEntrants</code> list and add them to the teesheet for as many as the value of <code>players</code> so if there are 3 players per start time. the first 3 people on the randomEntrants list would be added to the first teesheet as player 1, 2, 3 and player 4 would be left blank. It would then move to the next teesheet and add the next 3 etc etc until all players in the randomEntrants list had been added.</p>