title: Running a script having mongodb queries from mongodb shell
body: <p>I have a couple of Ids in my mongodb database document. I need to create indexes on these Ids through a script so that i do not have to run the ensureIndex command again and again.</p>
  
  <pre><code>db.getCollection("elements").ensureIndex({customerId:1});
  db.getCollection("elements").ensureIndex({userId:1});
  ........
  </code></pre>
  
  <p>I just run the script (that contains all these commands) and I should be done. Any idea how to run a script from mongodb shell? Also what should be the extension of the script?</p>
  
  <p>Juhi. </p>