Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-18 11:53:25 +00:00
parent d4311d3010
commit fbcf589c8c
26 changed files with 1216 additions and 1216 deletions

View File

@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
Endpoints:
## Update
## Create
Update a record in the database. Include an "id" in the record to update.
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
@@ -21,47 +21,21 @@ import(
"go.m3o.com/db"
)
// Update a record in the database. Include an "id" in the record to update.
func UpdateArecord() {
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Update(&db.UpdateRequest{
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"age": 43,
"age": 42,
"isActive": true,
"id": "1",
"name": "Jane",
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Truncate
Truncate the records in a table
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Count
@@ -90,6 +64,34 @@ func CountEntriesInAtable() {
})
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)
}
```
## ListTables
@@ -148,12 +150,12 @@ To: "examples3",
}
```
## Create
## Update
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
Update a record in the database. Include an "id" in the record to update.
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
```go
package example
@@ -165,15 +167,13 @@ import(
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
// Update a record in the database. Include an "id" in the record to update.
func UpdateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
rsp, err := dbService.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"isActive": true,
"id": "1",
"name": "Jane",
"age": 42,
"age": 43,
},
Table: "example",
@@ -240,12 +240,12 @@ Table: "example",
}
```
## DropTable
## Truncate
Drop a table in the DB
Truncate the records in a table
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
@@ -257,10 +257,10 @@ import(
"go.m3o.com/db"
)
// Drop a table in the DB
func DropTable() {
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.DropTable(&db.DropTableRequest{
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})