db service: Count endpoint (#236)

This commit is contained in:
Janos Dobronszki
2021-10-21 09:35:51 +01:00
committed by GitHub
parent 36b705930f
commit 2b6a219b0e
13 changed files with 384 additions and 118 deletions

View File

@@ -0,0 +1,6 @@
curl "https://api.m3o.com/v1/db/Count" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MICRO_API_TOKEN" \
-d '{
"table": "users"
}'

View File

@@ -0,0 +1,16 @@
package example
import (
"fmt"
"github.com/micro/services/clients/go/db"
"os"
)
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,12 @@
import * as db from "m3o/db";
// Count records in a table
async function CountEntriesInAtable() {
let dbService = new db.DbService(process.env.MICRO_API_TOKEN);
let rsp = await dbService.count({
table: "users",
});
console.log(rsp);
}
await CountEntriesInAtable();