mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 06:25:07 +00:00
Generate clients (#206)
This commit is contained in:
7
examples/db/read/curl/readRecords.sh
Executable file
7
examples/db/read/curl/readRecords.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/db/Read" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"query": "age == 43",
|
||||
"table": "users"
|
||||
}'
|
||||
17
examples/db/read/go/readRecords.go
Executable file
17
examples/db/read/go/readRecords.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/db"
|
||||
"os"
|
||||
)
|
||||
|
||||
// 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("MICRO_API_TOKEN"))
|
||||
rsp, err := dbService.Read(&db.ReadRequest{
|
||||
Query: "age == 43",
|
||||
Table: "users",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/db/read/node/readRecords.js
Executable file
13
examples/db/read/node/readRecords.js
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as db from "m3o/db";
|
||||
|
||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
async function ReadRecords() {
|
||||
let dbService = new db.DbService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await dbService.read({
|
||||
query: "age == 43",
|
||||
table: "users",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await ReadRecords();
|
||||
Reference in New Issue
Block a user