Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering MongoDB 4.x

You're reading from   Mastering MongoDB 4.x Expert techniques to run high-volume and fault-tolerant database solutions using MongoDB 4.x

Arrow left icon
Product type Paperback
Published in Mar 2019
Publisher Packt
ISBN-13 9781789617870
Length 394 pages
Edition 2nd Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Alex Giamas Alex Giamas
Author Profile Icon Alex Giamas
Alex Giamas
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Section 1: Basic MongoDB – Design Goals and Architecture FREE CHAPTER
2. MongoDB – A Database for Modern Web 3. Schema Design and Data Modeling 4. Section 2: Querying Effectively
5. MongoDB CRUD Operations 6. Advanced Querying 7. Multi-Document ACID Transactions 8. Aggregation 9. Indexing 10. Section 3: Administration and Data Management
11. Monitoring, Backup, and Security 12. Storage Engines 13. MongoDB Tooling 14. Harnessing Big Data with MongoDB 15. Section 4: Scaling and High Availability
16. Replication 17. Sharding 18. Fault Tolerance and High Availability 19. Other Books You May Enjoy

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, we have extracted data from Ethereum and loaded it into our MongoDB database. The relation of the blockchain to our database is shown in the following diagram:

Our data resides in two collections: blocks and transactions.

A sample block document has the following fields:

  • Number of transactions
  • Number of contracted internal transactions
  • Block hash
  • Parent block hash
  • Mining difficulty
  • Gas used
  • Block height

The following code shows the output data from a block:

> db.blocks.findOne()
{
"_id" : ObjectId("595368fbcedea89d3f4fb0ca"),
"number_transactions" : 28,
"timestamp" : NumberLong("1498324744877"),
"gas_used" : 4694483,
"number_internal_transactions" : 4...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime