Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-20 21:44:00 +00:00
parent 29cb72c55b
commit a6dc177797
28 changed files with 1634 additions and 1443 deletions

View File

@@ -36,12 +36,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
@@ -53,15 +53,43 @@ 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)
}
```
## ListTables
List tables in the DB
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// List tables in the DB
func ListTables() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.ListTables(&db.ListTablesRequest{
})
fmt.Println(rsp, err)
}
```
## RenameTable
@@ -127,12 +155,12 @@ Table: "example",
}
```
## Delete
## Truncate
Delete a record in the database by id.
Truncate the records in a table
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
@@ -144,12 +172,11 @@ import(
"go.m3o.com/db"
)
// Delete a record in the database by id.
func DeleteArecord() {
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
Table: "example",
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})
fmt.Println(rsp, err)
@@ -212,12 +239,12 @@ func CountEntriesInAtable() {
}
```
## ListTables
## Delete
List tables in the DB
Delete a record in the database by id.
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
```go
package example
@@ -229,38 +256,11 @@ import(
"go.m3o.com/db"
)
// List tables in the DB
func ListTables() {
// Delete a record in the database by id.
func DeleteArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.ListTables(&db.ListTablesRequest{
})
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",
rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
Table: "example",
})