That is why you seriously audit your tools and why many in the industry avoid Mongo like the plague. Controlling the byes that gets written to a file is actually not simple at all, and its a huge research problem as far as file systems of databases. I'm just saying, I don't think writing your own db is every a very good idea, unless it is SO simple that you would barely call it a DB.