View details Mongodb on Debian

2

I need a way to see the bd , collections, and MongoDb documents. Since I usually communicate with mongo using mongoose .

I would like to know a direct way from the console to access the characteristics of a bd that you have already created. With characteristics I mean how is structured a certain collection of objects, fields, validators, etc, that make it up as well as their documents.

So far I know that if I write mongo I get a shell that allows me to interact with mongodb , but I lack a little experience with this. Any help is appreciated.

    
asked by Theia 12.06.2017 в 04:23
source

2 answers

1

MongoDB - basic commands

Now if first we are going to enter our linux terminal or windows and access the mongo console, once we enter from our terminal we will use the command:
show dbs;
this command shows us the databases we have in mongodb:
use [nombre de la base];
with this command we use a database, this command also creates a database and will be listed with% show dbs ;
until we insert a document in the collection.
db.[coleccion].insert( [documento en formato JSON] ) ;
To insert and create a data collection in MongoDB we just use the statement insert and add the document (data) in JSON format, the collections are created automatically in mongodb once we insert an element or collection.
show collections;
This command shows us the collections available in the database, remember to first select the database with the command use .% db.[coleccion].find();
the find() command shows us the list of documents ("records") of a collection, we can filter or send to the find command to specify the results of our query.
db.[coleccion].find().pretty();
if we want the results to look much better or give a more visible output on the screen, we should only add to the pretty () query that will make the result look beautiful!

For more information about the JSON notation you can use this link link , you can find the mongodb documentation in this link to see in depth the commands shown here link

    
answered by 26.06.2017 / 21:26
source
-1

This link about basic Mongo shell commands (i.e. what you sign in when you type mongo ) can be useful:

link

    
answered by 23.06.2017 в 19:47