MongoDB is also a database, like MySQL, there are servers, databases, tables, records concepts. You can also use command operations in the terminal.
1. Connect MongoDB
MONGO 127.0.0.1:27017
2. Show all databases
Show DBS;
3. Using the Database
Use test;
4, view the database under the collection (table)
Show collections;
5. Manipulating a Collection
Db.person.find ();
6. View the database for the current operation
Db.getname ();
MongoDB execution JavaScript
MongoDB supports running JavaScript, which is basically the same as General JavaScript.
There are several ways to allow this:
1. Directly run the client in MongoDB connection. For example, edit and run JS in Robo 3T
2. MONGO--eval Run a script
Without entering interactive mode, run a MongoDB script directly under the command line of the OS.
Mongo127.0.0.1:27017/test--eval "Printjson (Db.users.findOne ())"
3, under the OS command line, run a JS file
MONGO 127.0.0.1:27017/testuserfindone.js
Content of Userfindone.js:
Printjson (Db.users.findOne ());
4, in MONGO Shell interactive mode, run a JS file
MONGO Test
Load ("/root/mongojs/userfindone.js")
MongoDB Common operations