https://github.com/go-serverless/k3d-mongodb-crud
  
  
    Building Serverless CRUD services in Go with OpenFaaS, Arkade, MongoDB and k3d 
    https://github.com/go-serverless/k3d-mongodb-crud
  
crud k3d kubernetes mongodb openfaas serverless serverless-crud-services
        Last synced: 8 days ago 
        JSON representation
    
Building Serverless CRUD services in Go with OpenFaaS, Arkade, MongoDB and k3d
- Host: GitHub
- URL: https://github.com/go-serverless/k3d-mongodb-crud
- Owner: go-serverless
- License: mit
- Created: 2020-03-29T05:17:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-27T02:53:30.000Z (about 4 years ago)
- Last Synced: 2025-04-06T15:47:41.220Z (7 months ago)
- Topics: crud, k3d, kubernetes, mongodb, openfaas, serverless, serverless-crud-services
- Language: Go
- Homepage: https://wingk-wong.blogspot.com/2020/03/building-serverless-crud-services-in-go_29.html
- Size: 3.91 KB
- Stars: 5
- Watchers: 0
- Forks: 1
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
- License: LICENSE
 
Awesome Lists containing this project
README
          # k3d-mongodb-crud
Building Serverless CRUD services in Go with OpenFaaS, Arkade, MongoDB and k3d
> This is just a learning playground
Check out the blog post [here](https://wingk-wong.blogspot.com/2020/03/building-serverless-crud-services-in-go_29.html)
### Create
```
curl http://127.0.0.1:8080/function/k3d-mongodb-crud --request POST
{"success":true, "message": "4 records have been inserted"}
```
Go to MongoDB, check the collection
```
> db.foo.find()
{ "_id" : ObjectId("5e8014f10c4812773ee77f16"), "bar" : "bar", "baz" : "baz" }
{ "_id" : ObjectId("5e8014f10c4812773ee77f17"), "bar" : "bar1", "baz" : "baz1" }
{ "_id" : ObjectId("5e8014f10c4812773ee77f18"), "bar" : "bar2", "baz" : "baz2" }
{ "_id" : ObjectId("5e8014f10c4812773ee77f19"), "bar" : "bar3", "baz" : "baz3" }
```
### Read
```
curl http://127.0.0.1:8080/function/k3d-mongodb-crud --request GET
[{"Bar":"bar","Baz":"baz"},{"Bar":"bar1","Baz":"baz1"},{"Bar":"bar2","Baz":"baz2"},{"Bar":"bar3","Baz":"baz3"}]
```
### Update 
```
curl http://127.0.0.1:8080/function/k3d-mongodb-crud --request PUT
{"success":true, "message": "bar1 has been updated to bar1-updated"}
```
Go to MongoDB, check the collection
```
> db.foo.find()
{ "_id" : ObjectId("5e8014f10c4812773ee77f16"), "bar" : "bar", "baz" : "baz" }
{ "_id" : ObjectId("5e8014f10c4812773ee77f17"), "bar" : "bar1-updated", "baz" : "baz1" }
{ "_id" : ObjectId("5e8014f10c4812773ee77f18"), "bar" : "bar2", "baz" : "baz2" }
{ "_id" : ObjectId("5e8014f10c4812773ee77f19"), "bar" : "bar3", "baz" : "baz3" }
```
### Delete
```
curl http://127.0.0.1:8080/function/k3d-mongodb-crud --request DELETE
{"success":true, "message": "bar1 has been deleted"}
```
```
> db.foo.find()
{ "_id" : ObjectId("5e8014f10c4812773ee77f17"), "bar" : "bar1-updated", "baz" : "baz1" }
{ "_id" : ObjectId("5e8014f10c4812773ee77f18"), "bar" : "bar2", "baz" : "baz2" }
{ "_id" : ObjectId("5e8014f10c4812773ee77f19"), "bar" : "bar3", "baz" : "baz3" }
```