CRUD + FileUpload in Golang using echo and MongoDB
- echo
- go mongodb driver
Main files:
- main.go
- fileUpload.go
main.go
CRUD operation on cookie database.
MongoDB
Database: mongo
Collection: cookies
Dummy data available in cookies.json
- Open MongoDB Compass
- Connect to mongodb://localhost:27017 (default port)
- Import cookies.json
Request from localhost:8080
:
- POST /cookies
payload: Cookies in request body
return insert operation info - GET /cookies
return all cookies in db - GET /cookies/
:tag
tag
path param of cookie
return cookie with thattag
- PATCH /cookies/
:tag
tag
path param of cookie
return patch operation info - DELETE /cookies/
:tag
tag
path param of cookie return delete count
fileUpload.go
Upload file into database using gridfs
Database: mongo
Collection: fs.files
and fs.chunks
- run via
or compile first
go run main.go <filename>
go build main.exe <filename>