MongoDB CRUD application showcasting how to use GRPC to communicate between a client and server. The client is build using the Cobra CLI library.
- MongoDB Database
- Golang installation
- GRPC as the communication protocol between the server and the client
- MongoDB as the database of the CRUD application
- Cobra for building a well structured and documented command line application
Building the proto file:
protoc pb/blog.proto --go_out=plugins=grpc:./pb
Starting the server:
go run server/server.go
Installing the CLI:
go install ./client/
Inserting a document:
client create --authorid "101010010" --content "Some great blog content" --title "Very great blog post"
Reading a document:
client read --blogid BLOG_ID
# For example:
client read --blogid 5f01cf70960b42b7d962acf3
Updating a document:
client update --id 5f01cf70960b42b7d962acf3 --title "Some great title" --content "Some great content" --authorid "100203900392840932875"
Deleting a document:
client delete --blogid 5f01cf70960b42b7d962acf3