$ db.myFirstCollection.find(): check if newUser can query documents. $ db.myFirstCollection.insert(): check the current user. $ db.createCollection('myFirstCollection'): create a collection named myFirstCollection. $ use dbTest: create a database named dbTest. You could also run $ docker exec -it MONGO_CONTAINER bash and after, $ mongo. $ docker exec -it MONGO_CONTAINER mongo: execute mongo command in the MONGO_CONTAINER directly in your shell. MONGO_CONTAINER container should be running. $ docker run -d -p 27017:27017 -name MONGO_CONTAINER mongo:latest: run MongoDB container in detached mode (running in background). I've decided to use Docker because it's easier to start and clean up the system after doing some tests. Of course, there are many more functionalities, but here I just focused on creating a Docker container, databases, collections, documents, adding users, performing some queries, dumping, and restoring databases. I create this cheat sheet because I need to work on a project that uses MongoDB, and doing the steps below gave me an overview of how MongoDB works. This tutorial shows how you can start and understand a bit more about MongoDB.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |