mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-23 15:51:24 +00:00
Commit from GitHub Actions (Generate Clients & Examples)
This commit is contained in:
@@ -34,6 +34,12 @@ func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
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
|
||||
func (t *DbService) ListTables(request *ListTablesRequest) (*ListTablesResponse, error) {
|
||||
rsp := &ListTablesResponse{}
|
||||
@@ -96,6 +102,13 @@ type DeleteRequest struct {
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type DropTableRequest struct {
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type DropTableResponse struct {
|
||||
}
|
||||
|
||||
type ListTablesRequest struct {
|
||||
}
|
||||
|
||||
@@ -141,13 +154,10 @@ type RenameTableResponse struct {
|
||||
}
|
||||
|
||||
type TruncateRequest struct {
|
||||
// Optional table name. Defaults to 'default'
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type TruncateResponse struct {
|
||||
// The table truncated
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
|
||||
@@ -79,5 +79,5 @@
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"types": "index.d.ts",
|
||||
"version": "1.0.738"
|
||||
"version": "1.0.741"
|
||||
}
|
||||
6
examples/db/dropTable/curl/dropTable.sh
Executable file
6
examples/db/dropTable/curl/dropTable.sh
Executable 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"
|
||||
}'
|
||||
17
examples/db/dropTable/go/dropTable.go
Executable file
17
examples/db/dropTable/go/dropTable.go
Executable 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)
|
||||
}
|
||||
12
examples/db/dropTable/node/dropTable.js
Executable file
12
examples/db/dropTable/node/dropTable.js
Executable 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();
|
||||
@@ -12,8 +12,8 @@ func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
},
|
||||
Table: "users",
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user