Learning about Blockchain explorer Mongodb

71 Likes Comment
  1. Setup a crypto coin blockchain explorer: I deployed a iquidus explorer.
  2. Remember some useful sql for Mongodb:


sudo service mongod start

# connect console commands


> show dbs;

> use tempdb;

> db.dropDatabase();
{ “dropped” : “tempdb”, “ok” : 1 }

List 100 richest holders:

db.addresses.aggregate([{ $group: { _id: “$a_id”, total: { $sum: “$balance” } } },{ $sort: { total: -1 } },{ $limit : 100 }]);

      Total current supply coins:

coin-cli gettxoutsetinfo
“total_amount”: 3286598798.90982342

Backup mongodb:

mongodump -d database-name -o folder-to-store-backup-db-files

Restore mongodb

mongorestore -d database-name folder-to-store-backup-db-files

Display the last record in a collection of a mongo database:


List all databases with collections size in mongodb server:

mongo --eval " db.getMongo().getDBNames().forEach( function(v, i){ db.getSiblingDB(v).getCollectionNames().forEach( function(vv, ii){ print (v + ',' + vv + ',' + db.getSiblingDB(v).getCollection(vv).count() ) } ) } ) "

Backup & restore mongodb database:https://stackoverflow.com/questions/11255630/how-to-export-all-collections-in-mongodb

You might like

About the Author: Toc Xoan

This guy likes taking photos, hunting cheap tours, exploring the unique culture of every cities of Vietnam. Contact: [email protected]. I've created a dogecoin wallet to receive blog funding: DE6F5FisSCy7yz5rpHY1ChMSGYnDMpFZ1Q

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.