I'm a beginner with MongoDB and I've some questions:
When I'm connected to Mongo, and i execute show dbs
I see 2 databases: admin
and local
. What's their role? Then if I execute an insert command like db.foo.insert({"value":"mongo"})
, the test
database appears. Why? How can i specify a custom name for a database?
With show dbs
I get the databases (somehow like show databases
in sql), how can I then list the collections inside a database (I would use show tables
in sql)?
When executing a command, the MongoDB tutorial always uses the db
object. Is it the main object (a sort of "connection" object) that has to used for executing commands or it's something else?
Thanks!
What is a covered query in MongoDB? A covered query is the one in which: fields used in the query are part of an index used in the query, and. the fields returned in the results are in the same index.
MongoDB is a Document Database, which stores all schema and records in documents using a JSON (JavaScript Object Notation) like syntax. If you are familiar with JavaScript, JSON, and Web Development, MongoDB will not be very difficult to understand, and these courses will definitely help you to get a good start.
MongoDB is an open source NoSQL database management program. NoSQL is used as an alternative to traditional relational databases. NoSQL databases are quite useful for working with large sets of distributed data. MongoDB is a tool that can manage document-oriented information, store or retrieve information.
admin
and local
contain various settings local to the server, like users who are authenticated to connect. Under beginner usage, you shouldn't need to worry about them at all. By default you connect to a database named test
. To connect to a new database, just use databasename
from the mongo command line, or mongo databasename
from your OS shell.use [database_name]
and then show collections
db
object is your root handle to the currently-selected database on the mongo commmand line. The command line is really just a Javascript command line, and there are various mongodb-specific objects and functions exposed that let you do stuff. Try help()
for a full listing.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With