// script to read documents from the test.types collection created by `write_types.js`

var MongoClient = require('mongodb').MongoClient,
    assert = require('assert');

var url = 'mongodb://localhost:27017/test';

MongoClient.connect(url, function(err, db) {
  assert.ifError(err);

  // Get the documents collection
  var collection = db.collection('types');

  // find all documents and print them out
  collection.find({}).toArray(function(err, docs) {
    assert.ifError(err);

    // don't use JSON.stringify here, it loses a lot of information like _bsontype
    console.log(docs);
    db.close();
  });
});


@@ -79,16 +79,58 @@
 ypes.js%60
+%0Avar BSON = require('bson').BSONPure.BSON;
 %0A%0Avar Mo
@@ -251,16 +251,17 @@
 test';%0A%0A
+%0A
 MongoCli
@@ -395,16 +395,30 @@
 ('types'
+, %7Braw: false%7D
 );%0A%0A  //
@@ -478,16 +478,32 @@
 ind(%7B%7D).
+sort(%7Bbtype:1%7D).
 toArray(
@@ -641,24 +641,158 @@
     
-console.log(docs
+docs.forEach(function (doc) %7B%0A      console.log(doc.x, doc.btype, doc.comment);%0A      console.log()%0A      // console.log(BSON.deserialize(doc));%0A    %7D
 );%0A 

disable raw mode. print x, btype, comment only.