Currently works with Mongo Atlas, can work with local mongo setup also
go run main.go
Pinged your deployment. You successfully connected to MongoDB!
^C2024/02/01 19:27:02 Program killed !
curl:
curl --location 'http://localhost:9000/user/' \
--header 'Content-Type: application/json' \
--data '{
"Name": "sudhanshu",
"Gender": "male",
"Age": 24
}'
output:
Inserted Id: e�����t�g�`a
Inserted Obj: {
"id": "65bba791e1ed7405678a6061",
"name": "Sudhanshu",
"gender": "male",
"age": 24
}
curl:
curl --location 'http://localhost:9000/user/65bba791e1ed7405678a6061'
output:
{
"id": "65bba791e1ed7405678a6061",
"name": "Sudhanshu",
"gender": "male",
"age": 24
}
curl:
curl --location --request DELETE 'http://localhost:9000/user/65bba791e1ed7405678a6061'
output:
Deleted user: {
"id": "65bba791e1ed7405678a6061",
"name": "Sudhanshu",
"gender": "male",
"age": 24
}
brew services start mongodb-community@7.0
brew services stop mongodb-community@7.0
mongod --config /usr/local/etc/mongod.conf --fork
mongosh
brew services list
ps aux | grep -v grep | grep mongod