title: How can I know in mongodb if a field is a Date type?
body: <p>I'm working on a NodeJS+Mongodb app. </p>
  
  <p>I've just inserted one record into mongodb using the console client:</p>
  
  <pre><code>db.user.save({myId:11111, myDate: ISODate("2012-04-30T00:00:00.000Z")})
  </code></pre>
  
  <p>The thing is, when I'm in node.js, I need to know if "myDate" field is really a Date type, in order to perform a data range query, etc. </p>
  
  <p>I tried the following. </p>
  
  <p><strong>1. on the mongo client console:</strong>  </p>
  
  <pre><code>typeof db.user.myDate --&gt; It returns "Object"
  db.user.myDate instanceof Date --&gt; It returns "false"
  </code></pre>
  
  <p><strong>2. on my Nodejs code,</strong> </p>
  
  <p>I'm trying to get the type calling this <code>getTypeMembers</code> function. (obj comming from a db query)</p>
  
  <pre><code>exports.getTypeMembers = function(obj) {
  obj = JSON.parse(JSON.stringify(obj)
  
  for(var _k in obj){
      if(Object.prototype.toString.call(obj[_k]) === '[object Array]' ) {
          obj[_k] = "Array";
      }
      else if(typeof(obj[_k])=="object"){
          obj[_k] = this.getTypeMembers(obj[_k]);
      }else{
          obj[_k] = typeof (obj[_k]);
      }
  }
  return obj;
  </code></pre>
  
  <p>};</p>
  
  <p>What I get in this method is: <code>"String"</code>, when I need <code>"Date"</code></p>
  
  <p>Is there any other way to get some kind of <code>"Date"</code> result?</p>