Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-25 12:46:02 +00:00
parent 341d0e9563
commit bcf8833d06
24 changed files with 1341 additions and 1341 deletions

View File

@@ -26,10 +26,10 @@ func CreateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"name": "Jane",
"age": 42,
"isActive": true,
"id": "1",
"name": "Jane",
},
Table: "example",
@@ -67,12 +67,12 @@ Table: "example",
}
```
## Delete
## Truncate
Delete a record in the database by id.
Truncate the records in a table
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
@@ -84,12 +84,39 @@ import(
"go.m3o.com/db"
)
// Delete a record in the database by id.
func DeleteArecord() {
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
Table: "example",
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## DropTable
Drop a table in the DB
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Drop a table in the DB
func DropTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.DropTable(&db.DropTableRequest{
Table: "example",
})
fmt.Println(rsp, err)
@@ -156,12 +183,12 @@ Table: "example",
}
```
## Truncate
## Delete
Truncate the records in a table
Delete a record in the database by id.
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
```go
package example
@@ -173,39 +200,12 @@ import(
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
// Delete a record in the database by id.
func DeleteArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## DropTable
Drop a table in the DB
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Drop a table in the DB
func DropTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.DropTable(&db.DropTableRequest{
Table: "example",
rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
Table: "example",
})
fmt.Println(rsp, err)