Files
services/examples/db/create/go/createARecord.go
Dominic Wong 40006de6ee Fix panic in vehicle service (#226)
* fix panic

* Commit from GitHub Actions (Publish APIs & Clients)

Co-authored-by: domwong <domwong@users.noreply.github.com>
2021-10-08 11:55:02 +01:00

23 lines
489 B
Go
Executable File

package example
import (
"fmt"
"github.com/micro/services/clients/go/db"
"os"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"isActive": true,
"id": "1",
"name": "Jane",
"age": 42,
},
Table: "users",
})
fmt.Println(rsp, err)
}