26

I'm trying to find data using native Mongo queries, but can't do it. It seems mongoDB Compass only provides filter property for fetching data.

As in case of SQL's (say phpmyadmin, mysqlWorkbench, toad), we can easily execute native queries directly in the QueryEditor. Similarly Is there any console (query editor) in mongodb compass where I can execute direct queries? If yes, then tell me the breadcrumb.

Note: I don't want to use robomongo, robo3T and other mongo UI tools.

Jabongg
  • 2,099
  • 2
  • 15
  • 32

5 Answers5

15

Compass provide the console at very bottom to run your query as you can run in the command line - you can just write your query after clicking on the mongosh console

something like - db.yourcollection.find({id: {$eq: "00"}}).pretty()

viveksharma
  • 557
  • 4
  • 9
8

Looks like they're adding a shell to Compass:

https://www.mongodb.com/blog/post/new-compass-comes-with-shell

"In Compass 1.22 Beta we are introducing the integrated MongoDB Shell, which allows you to run database commands and scripts directly from Compass."

JosephScript
  • 336
  • 4
  • 8
7

I like to use Robo3T (https://robomongo.org/), which has a nice interface and is not as restrictive as the Compass Query bars

rlpatrao
  • 565
  • 1
  • 8
  • 15
  • Status as today Robo3T supports MongoDB up to version 4.0. Unfortunately MongoDB 4.2 is not supported yet in Robo3T :-( – Fuzzzzel Jan 09 '20 at 12:28
  • I have recently found that certain queries don't work in 3T. Like those involving arrayFilters. – hvolmer Apr 09 '20 at 16:37
1

Unable to do this in Mongodb Compass, you can use other tools,such as "NoSQLBooster for MongoDB"

mfkvfn
  • 11
  • 2
0

Yes, Mongo compass provides only filter option(Query Bar) to do queries on specific collection.

To get better understanding about how to do queries in query bar refer this

Compass Documentation : Schema-Query Bar

Also have a look at this tutorial MongoDB Compass Query Building

Arpan Arora
  • 109
  • 7
  • 3
    So I understand it's not possible to run a query. How do we do that, then? What are the other options? – alexkovelsky Aug 14 '19 at 18:34
  • @Jeremie Definitely scripts are far better than using any visualisation tool but what was asked in this context was totally different that was specifically for compass. – Arpan Arora Mar 24 '20 at 18:02
  • I understand, but the aim is to answer the user's question :). It's simply impossible to do it with Compass, user has no other option but use another tool instead like robo3t if he wants to use the shell. – Jeremie Mar 25 '20 at 19:07