mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-22 07:15:25 +00:00
db service: Count endpoint (#236)
This commit is contained in:
@@ -16,6 +16,12 @@ type DbService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Count records in a table
|
||||
func (t *DbService) Count(request *CountRequest) (*CountResponse, error) {
|
||||
rsp := &CountResponse{}
|
||||
return rsp, t.client.Call("db", "Count", request, rsp)
|
||||
}
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
rsp := &CreateResponse{}
|
||||
@@ -46,6 +52,14 @@ func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
return rsp, t.client.Call("db", "Update", request, rsp)
|
||||
}
|
||||
|
||||
type CountRequest struct {
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type CountResponse struct {
|
||||
Count int32 `json:"count"`
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// JSON encoded record or records (can be array or object)
|
||||
Record map[string]interface{} `json:"record"`
|
||||
|
||||
Reference in New Issue
Block a user