Commit from GitHub Actions (Generate Clients & Examples)

This commit is contained in:
asim
2021-11-16 13:39:32 +00:00
parent cc7d1911d5
commit 92cfa38f25
6 changed files with 50 additions and 5 deletions

View File

@@ -34,6 +34,12 @@ func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
return rsp, t.client.Call("db", "Delete", request, rsp) return rsp, t.client.Call("db", "Delete", request, rsp)
} }
// Drop a table in the DB
func (t *DbService) DropTable(request *DropTableRequest) (*DropTableResponse, error) {
rsp := &DropTableResponse{}
return rsp, t.client.Call("db", "DropTable", request, rsp)
}
// List tables in the DB // List tables in the DB
func (t *DbService) ListTables(request *ListTablesRequest) (*ListTablesResponse, error) { func (t *DbService) ListTables(request *ListTablesRequest) (*ListTablesResponse, error) {
rsp := &ListTablesResponse{} rsp := &ListTablesResponse{}
@@ -96,6 +102,13 @@ type DeleteRequest struct {
type DeleteResponse struct { type DeleteResponse struct {
} }
type DropTableRequest struct {
Table string `json:"table"`
}
type DropTableResponse struct {
}
type ListTablesRequest struct { type ListTablesRequest struct {
} }
@@ -141,13 +154,10 @@ type RenameTableResponse struct {
} }
type TruncateRequest struct { type TruncateRequest struct {
// Optional table name. Defaults to 'default'
Table string `json:"table"` Table string `json:"table"`
} }
type TruncateResponse struct { type TruncateResponse struct {
// The table truncated
Table string `json:"table"`
} }
type UpdateRequest struct { type UpdateRequest struct {

View File

@@ -79,5 +79,5 @@
"prepare": "npm run build" "prepare": "npm run build"
}, },
"types": "index.d.ts", "types": "index.d.ts",
"version": "1.0.738" "version": "1.0.741"
} }

View File

@@ -0,0 +1,6 @@
curl "http://localhost:8080/db/DropTable" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MICRO_API_TOKEN" \
-d '{
"table": "users"
}'

View File

@@ -0,0 +1,17 @@
package example
import (
"fmt"
"os"
"github.com/micro/services/clients/go/db"
)
// Drop a table in the DB
func DropTable() {
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := dbService.DropTable(&db.DropTableRequest{
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,12 @@
const { DbService } = require("m3o/db");
// Drop a table in the DB
async function dropTable() {
let dbService = new DbService(process.env.MICRO_API_TOKEN);
let rsp = await dbService.dropTable({
table: "users",
});
console.log(rsp);
}
dropTable();

View File

@@ -12,8 +12,8 @@ func UpdateArecord() {
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN")) dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := dbService.Update(&db.UpdateRequest{ rsp, err := dbService.Update(&db.UpdateRequest{
Record: map[string]interface{}{ Record: map[string]interface{}{
"age": 43,
"id": "1", "id": "1",
"age": 43,
}, },
Table: "users", Table: "users",
}) })