title: PyMongo: Using $push to update an existing document with a reference to another document
body: <p>I have a <strong>teams</strong> collection and a <strong>players</strong> collection.  I am trying to insert documents into the <strong>teams* collection from the **players</strong> collection using $push.</p>
  
  <p>Here are the data models for both:</p>
  
  <p>Teams:</p>
  
  <pre><code>        {
              "team_id": 1,
              "team_name": team_name,
              "general_manager": general_manager,
              "players": [
  
              ]
          }
  </code></pre>
  
  <p>Players:</p>
  
  <pre><code>        {
              "_id": "5c076550c779ce4fa2d4c9fd"
              "first_name": first_name,
              "last_name": last_name,
          }
  </code></pre>
  
  <p>Here is the code I'm using:</p>
  
  <pre><code>        player = players.find_one({ "$and": [
          {"first_name": first_name},
          {"last_name": last_name}] })
  
  
      teams.update(
          {"team_name": team_name},
          {"$push":
               {"players": {
                   "$ref": "players",
                   "$id": player["_id"],
                   "$db": db
               }}})
  </code></pre>
  
  <p>When I execute this, I get the following error message: </p>
  
  <p>pymongo.errors.WriteError: Found $id field without a $ref before it, which is invalid.</p>
  
  <p>What am I doing wrong?  Thanks in advance!</p>