title: Return Random Result from JSON using PyMongo
body: <p>I'm attempting to retrieve a random result from a collection of JSON data using PyMongo. I'm using Flask and MongoDB. Here is how it is set up:</p>
  
  <pre><code>def getData():
      dataCollection = db["data"]
      for item in dataCollection.find({},{"Category":1,"Name":1,"Location":1,"_id":0}):
          return (jsonify(item)
  </code></pre>
  
  <p><code>return (jsonify(item)</code> returns 1 result and it is always the first one. How can I randomize this?</p>
  
  <p>I tried importing the random module (<code>import random</code>) and switched the last line to <code>random.choice(jsonify(item)</code> but that results in an error.</p>
  
  <p>Here is what the data looks like that was imported into MongoDB:</p>
  
  <pre><code>[
    {
      "Category":"Tennis",
      "Name":"ABC Courts",
      "Location":"123 Fake St"
    },
    {
      "Category":"Soccer",
      "Name":"XYZ Arena",
      "Location":"319 Ace Blvd"
    },
    {
      "Category":"Basketball",
      "Name":"Dome Courts",
      "Location":"8934 My Way"
    },
  ]
  </code></pre>