title: How do I remove an array item in Mongodb / Golang?
body: <p>I have the following data structure, and I'm attempting to remove an item from the 'artists' array.</p>
  
  <pre><code>[
      {
          "id": "56b26eeb4a876400011369e9",
          "name": "Ewan Valentine",
          "email": "ewan@test.com",
          "artists": [
              "56b26f334a876400011369ea",
              "56b2702881318d0001dd1441",
              "56b2746fdf1d7e0001faaa92",
          ],
          "user_location": "Manchester, UK"
      }
  ]
  </code></pre>
  
  <p>Here's my function...</p>
  
  <pre><code>// Remove artist from user
  func (repo *UserRepo) RemoveArtist(userId string, artistId string) error {
      change := bson.M{"artists": bson.M{"$pull": bson.ObjectIdHex(artistId)}}
      fmt.Println(userId)
      err := repo.collection.UpdateId(bson.ObjectIdHex(userId), change)
      return err
  }
  </code></pre>
  
  <p>I'm getting the following error:</p>
  
  <pre><code>{
    "_message": {
      "Err": "The dollar ($) prefixed field '$pull' in 'artists.$pull' is not valid for storage.",
      "Code": 52,
      "N": 0,
      "Waited": 0,
      "FSyncFiles": 0,
      "WTimeout": false,
      "UpdatedExisting": false,
      "UpsertedId": null
    }
  }
  </code></pre>