It is understandable that since the database is schema less we are not able to But if we take one record e.g db.collectionname.findOne(), it is not schema less. It has fixed attributes. How do I get that attribute less ?
the code:
> db.mycoll.insert( {num:3, text:"smth", date: new Date(), childs:[1,2,3]})
> var rec = db.mycoll.findOne();
> for (key in rec) {
var val = rec[key];
print( key + "(" + typeof(val) + "): " + val ) }
will print:
_id(object): 4e2d688cb2f2b62248c1c6bb
num(number): 3
text(string): smth
date(object): Mon Jul 25 2011 15:58:52 GMT+0300
childs(object): 1,2,3
(javascript array and date are just "object")
This shows "schema" of only top level, if you want to look deeper, some recursive tree-walking function is needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With