Cyberithub

How to query data from MongoDB using IntelliShell in Studio 3T Free Version?

Advertisements

In this article, we will see how to query data from MongoDB using IntelliShell in Studio 3T Free Version. This article focuses more on capability which users are having to query data from MongoDB in sql format but as soon as user either switches to free version from Pro or Ultimate editions or trial version gets expired, this capability disappears and now sql user might struggle to query data. The only option now available to query data is through IntelliShell which only takes MongoDB's native queries written in MongoDB Query Language(MQL). So now the question comes how to use MongoDB's native queries to query data from collections using IntelliShell in Studio 3T.

 

How to query data from MongoDB using IntelliShell in Studio 3T Free Version?

How to query data from MongoDB using IntelliShell in Studio 3T Free Version?

Also Read: Solved "pg_restore: error: input file appears to be a text format dump"

Here we are going look into steps that you can follow to query data from database using IntelliShell in Studio 3T.

  • Open Studio 3T
  • Connect to your Database
  • Go to your Collection
  • Select your collection and right click on it.
  • Click on Open IntelliShell

You will see an IntelliShell opened that can now be used to run either MongoDB scripts or MongoDB query statements. To understand this further, let's take an example scenario where we have to retrieve a document with specific id in example collection under cyberithub-db.

  • Database: cyberithub-db
  • Collection: example
  • id: 87304759562943acbd849

To retrieve document with a specific id from a collection in MongoDB, use below query syntax:-

db.<collection_name>.find({_id: ObjectId("<id>")});

So for our scenario, to retrieve document with _id 87304759562943acbd849 from example collection, use below query in IntelliShell:-

db.example.find({_id: ObjectId("87304759562943acbd849")});

To run query, click on Run statement at cursor(F6) button. It will run the query. If the document exist then it will show on output or else it will show an empty result.

It is possible that you would see document on the output like below where one or more than one column shows n number of fields(as you see carSpec in our case). To check that field, you can just click on it to go inside and see the value.

How to query data from MongoDB using IntelliShell in Studio 3T Free Version? 2

Further also if it shows  any column with n number of fields then you have to again click on it to see the value and so on. This way you have to check the output shown. Hope this information is useful for you. Please let me know your feedback in the comment box.

Leave a Comment