Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-20 22:01:00 +00:00
parent 0d60904f8a
commit e59891fea8
25 changed files with 1246 additions and 1246 deletions

View File

@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
Endpoints:
## 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)
}
```
## Truncate
Truncate the records in a table
@@ -61,12 +32,12 @@ func TruncateTable() {
}
```
## DropTable
## Count
Drop a table in the DB
Count records in a table
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go
package example
@@ -78,10 +49,10 @@ import(
"go.m3o.com/db"
)
// Drop a table in the DB
func DropTable() {
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.DropTable(&db.DropTableRequest{
rsp, err := dbService.Count(&db.CountRequest{
Table: "example",
})
@@ -152,12 +123,12 @@ Table: "example",
}
```
## Update
## Read
Update a record in the database. Include an "id" in the record to update.
Read data from a table. Lookup can be by ID or via querying any field in the record.
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
```go
package example
@@ -169,14 +140,11 @@ import(
"go.m3o.com/db"
)
// Update a record in the database. Include an "id" in the record to update.
func UpdateArecord() {
// 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.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"id": "1",
"age": 43,
},
rsp, err := dbService.Read(&db.ReadRequest{
Query: "age == 43",
Table: "example",
})
@@ -213,12 +181,12 @@ Table: "example",
}
```
## Count
## Update
Count records in a table
Update a record in the database. Include an "id" in the record to update.
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
```go
package example
@@ -230,10 +198,42 @@ import(
"go.m3o.com/db"
)
// Count records in a table
func CountEntriesInAtable() {
// 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.Count(&db.CountRequest{
rsp, err := dbService.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"id": "1",
"age": 43,
},
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",
})