Learn how to access your API node MongoDB instance.
The REST Gateway offers a broad range of endpoints so that you don’t have to connect to MongoDB. Still, if you are developing new plugins for Symbol, or analyzing extensive blockchain data, you might want to consider connecting to MongoDB directly.
By the end of this guide, you will be connected to your API node database instance and doing some basic queries.
For this tutorial, we are going to use Robo 3T (formerly RoboMongo), a cross-platform MongoDB management tool, to interact with the database.
In case of doubt, follow the official installation docs.
docker ps
.docker ps | grep mongo
ea62f033d2a6 mongo "docker-entrypoint.s…" 9 minutes ago 27017/tcp api-assembly_db_1
docker inspect <ID>
.docker inspect ea62f033d2a6 | grep "IPAddress"
"SecondaryIPAddresses": null,
"IPAddress": "",
"IPAddress": "172.20.0.7",
Go to the SSH tab and add the server’s details:
Replace the SSH Address, username, and authentication method.
Note
Only use this method to read from the database. Do not alter any document directly on MongoDB.
2. In most cases, you may want to filter a set of entries by one of its attributes. To filter, for example, a given transaction type, write a query with the following format on Robo 3T shell:
db.getCollection('transactions').find( { "transaction.type": 16724})
For other advanced queries, check the Robo3T docs.
Did you find what you were looking for? Give us your feedback.