I showed you how to use mongodb easily in this repo
- Golang
- MongoDb
- Docker
- Gin web framework
First we launch mongodb with docker
docker run -d -p 2717:27017 -v d:/mongodata:/data/db --name mymongo mongo
curl -X POST -H "Content-Type: application/json" \
-d '{"name": "baran can", "status": true, "balance":100}' \
http://localhost:8080/account
curl http://localhost:8080/account/62250425f537d1628ef6fb6f
{
"data": [
{
"_id": "62250425f537d1628ef6fb6f",
"balance": 50,
"name": "baran",
"status": true
}
],
"message": "ok"
}
curl -X PUT -H "Content-Type: application/json" \
-d '{"id":"62250425f537d1628ef6fb6f", "balance":100}' \
http://localhost:8080/add/money
curl -X PUT -H "Content-Type: application/json" \
-d '{"id":"62250425f537d1628ef6fb6f", "balance":100}' \
http://localhost:8080/reduce/money