Aggregation use case

In this rather lengthy section, we will use the aggregation framework to process data from the Ethereum blockchain.

Using our Python code from https://github.com/agiamas/mastering-mongodb/tree/master/chapter_5, we have extracted data from Ethereum and loaded it into our MongoDB database.

Our data resides in two collections, blocks and transactions.

A sample block document has the following fields:

  • Number of transactions
  • Number of contract internal transactions
  • Block hash
  • Parent block hash
  • Mining difficulty
  • Gas used
  • Block height
> db.blocks.findOne(){"_id" : ObjectId("595368fbcedea89d3f4fb0ca"),"number_transactions" : ...

Get Mastering MongoDB 3.x now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.