Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-20 14:08:38 +00:00
parent ffe132871c
commit 83d47cea87
26 changed files with 1458 additions and 1458 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,48 +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{}{
"id": "1",
"age": 43,
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Read
Read data from a table. Lookup can be by ID or via querying any field in the record.
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Read data from a table. Lookup can be by ID or via querying any field in the record.
func ReadRecords() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Read(&db.ReadRequest{
Query: "age == 43",
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Delete
@@ -92,6 +65,34 @@ 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)
}
```
## DropTable
@@ -151,12 +152,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
@@ -168,15 +169,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",
@@ -185,12 +184,12 @@ Table: "example",
}
```
## Truncate
## Read
Truncate the records in a table
Read data from a table. Lookup can be by ID or via querying any field in the record.
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
```go
package example
@@ -202,11 +201,12 @@ import(
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
// Read data from a table. Lookup can be by ID or via querying any field in the record.
func ReadRecords() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
rsp, err := dbService.Read(&db.ReadRequest{
Query: "age == 43",
Table: "example",
})
fmt.Println(rsp, err)