Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2021-12-16 19:24:48 +00:00
parent 292001f3f2
commit a6c66fb76a
26 changed files with 1245 additions and 1245 deletions

View File

@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
Endpoints:
## DropTable
## Create
Drop a table in the DB
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
@@ -21,10 +21,76 @@ import(
"go.m3o.com/db"
)
// Drop a table in the DB
func DropTable() {
// 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.DropTable(&db.DropTableRequest{
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"isActive": true,
"id": "1",
"name": "Jane",
"age": 42,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Update
Update a record in the database. Include an "id" in the record to update.
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// 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.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"id": "1",
"age": 43,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Count
Count records in a table
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
Table: "example",
})
@@ -86,66 +152,6 @@ To: "examples3",
})
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)
}
```
## Update
Update a record in the database. Include an "id" in the record to update.
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// 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.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"id": "1",
"age": 43,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Read
@@ -206,12 +212,12 @@ Table: "example",
}
```
## Count
## Truncate
Count records in a table
Truncate the records in a table
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
@@ -223,10 +229,10 @@ import(
"go.m3o.com/db"
)
// Count records in a table
func CountEntriesInAtable() {
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})
@@ -234,12 +240,12 @@ func CountEntriesInAtable() {
}
```
## Create
## DropTable
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
Drop a table in the DB
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
```go
package example
@@ -251,17 +257,11 @@ import(
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
// Drop a table in the DB
func DropTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "example",
rsp, err := dbService.DropTable(&db.DropTableRequest{
Table: "example",
})
fmt.Println(rsp, err)