title: How to create a collection in MongoDB using SPRING data
body: <p>Am using Spring-Data-Mongo to access do CRUD operations on my mongo database. I execute the below line</p>
  
  <pre><code>DB db = mongoTemplate.getDb()
  </code></pre>
  
  <p>When am in debug mode I can see that db._collections properties has 4 values (collections that I inserted). But when I query for </p>
  
  <pre><code>db.getCollectionNames()
  </code></pre>
  
  <p>I get zero collections back. Why is that? Same is also true when I do </p>
  
  <pre><code>db.getCollection("collectionName")
  </code></pre>
  
  <p>But I know the collections do exists because when I do something like</p>
  
  <pre><code>mongoTemplate.createCollection("collectionName");
  </code></pre>
  
  <p>I get an exception saying that collection already exists. Can anyone please explain what I might be missing</p>