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

@@ -6,6 +6,10 @@ export class DbService {
constructor(token: string) {
this.client = new m3o.Client({ token: token });
}
// Count records in a table
count(request: CountRequest): Promise<CountResponse> {
return this.client.call("db", "Count", request) as Promise<CountResponse>;
}
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
create(request: CreateRequest): Promise<CreateResponse> {
return this.client.call("db", "Create", request) as Promise<CreateResponse>;
@@ -32,6 +36,14 @@ export class DbService {
}
}
export interface CountRequest {
table?: string;
}
export interface CountResponse {
count?: number;
}
export interface CreateRequest {
// JSON encoded record or records (can be array or object)
record?: { [key: string]: any };