Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-03-02 16:46:27 +00:00
parent 95340f33e9
commit beca62373a
21 changed files with 1220 additions and 1220 deletions

View File

@@ -4,40 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
Endpoints:
## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// 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.Create(&db.CreateRequest{
Record: map[string]interface{}{
"name": "Jane",
"age": 42,
"isActive": true,
"id": "1",
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## DropTable
Drop a table in the DB
@@ -66,12 +32,12 @@ func DropTable() {
}
```
## Count
## ListTables
Count records in a table
List tables in the DB
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
```go
package example
@@ -83,11 +49,39 @@ import(
"go.m3o.com/db"
)
// Count records in a table
func CountEntriesInAtable() {
// List tables in the DB
func ListTables() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
Table: "example",
rsp, err := dbService.ListTables(&db.ListTablesRequest{
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a record in the database by id.
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Delete a record in the database by id.
func DeleteArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
Table: "example",
})
fmt.Println(rsp, err)
@@ -153,35 +147,6 @@ Table: "example",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a record in the database by id.
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Delete a record in the database by id.
func DeleteArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Truncate
@@ -212,12 +177,12 @@ func TruncateTable() {
}
```
## ListTables
## Count
List tables in the DB
Count records in a table
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go
package example
@@ -229,11 +194,12 @@ import(
"go.m3o.com/db"
)
// List tables in the DB
func ListTables() {
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.ListTables(&db.ListTablesRequest{
rsp, err := dbService.Count(&db.CountRequest{
Table: "example",
})
fmt.Println(rsp, err)
@@ -268,3 +234,37 @@ To: "examples3",
}
```
## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// 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.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```