An example of how you would connect to MongoDB and perform basic CRUD operations.
There's another example that performs the same operation but with a pre-defined schema.
Here's a sequence of steps to run this project.
-
Launch a shell session and start MongoDB (server) via Docker:
$ docker-compose up
-
You can connect to Mongo via the console:
$ docker exec -it mongo mongo -u nobody -p secrets go-recipes
-
Run Go program.
$ go run ./main.go
-
When you are done, just shut mongo down.
$ docker-compose down $ docker-compose down
-
Alternatively, you can run everything with just 2 commands.
$ make run $ make teardown # Run this to remove container