title: The "right way" to load, crunch and pass variables from Express to Jade
body: <p>I'm building an app in Express. In one of the views a logged in Superadmin is able to view all available clients/user. In this view I am loading a bunch of client data from my MongoDB/Mongoose with a simple: </p>
  
  <pre><code>app.get('/superadmin', function(req, res) {    
    Client.find({}, '_id company monthly_cost sms_cost', function (err, docs) ...
  </code></pre>
  
  <p>As you can see above i have choosen only the values that I need from the query. These four are: "_id", "company", "monthly_cost" and "sms_cost"</p>
  
  <p>From the "_id" i can get a "creation date" by using .getTimestamp(), but the Dateobject this function return is bit to complex formated. I need a simpler date, something like: (YYYY-MM-DD). Im thinking of using a small node plugin like dateformat or possibly writing a very simple function that extract the YYYY, MM and DD from the IsoDate object and saving this in a new variable/array</p>
  
  <p>Now to my questions:</p>
  
  <p>Q1) WHERE is actually the right place for this code? I'm currently putting it inside the route handler above... consequently it will follow right below the code above. I'm thinking this is principally the right way according to a MVC pattern. I'm thinking I dont want to put this code in the Jade view template?</p>
  
  <p>Q2) IN WHAT FORM should i save this data and HOW should i pass it along to Jade. Should I somehow add it to the "docs"-data... that is, the data I extract from my DB. Or should I rather put this creationDate in a separate array which i pass to jade side by side with the original DB-data. </p>
  
  <p>I hope my questions are clear enough!</p>