Files
services/db/proto/db.proto

79 lines
1.7 KiB
Protocol Buffer

syntax = "proto3";
import "google/protobuf/struct.proto";
package db;
option go_package = "./proto;db";
service Db {
rpc Create(CreateRequest) returns (CreateResponse) {}
rpc Read(ReadRequest) returns (ReadResponse) {}
rpc Update(UpdateRequest) returns (UpdateResponse) {}
rpc Delete(DeleteRequest) returns (DeleteResponse) {}
rpc Truncate(TruncateRequest) returns (TruncateResponse) {}
}
message ReadRequest {
string table = 1;
// Read by id. Equivalent to 'id == "your-id"'
string id = 2;
// Examples: 'age >= 18', 'age >= 18 and verified == true'
// Comparison operators: '==', '!=', '<', '>', '<=', '>='
// Logical operator: 'and'
// Dot access is supported, eg: 'user.age == 11'
// Accessing list elements is not supported yet.
string query = 3;
int32 offset = 4;
// Default limit is 25.
// Maximum limit is 1000. Anything higher will return an error.
int32 limit = 5;
// field name to order by
string orderBy = 6;
// 'asc' (default), 'desc'
string order = 7;
}
message ReadResponse {
// JSON encoded records
repeated google.protobuf.Struct records = 1;
}
message CreateRequest {
string table = 1;
// JSON encoded record or records (can be array or object)
google.protobuf.Struct record = 2;
}
message CreateResponse {
// The id of the record
string id = 1;
}
message UpdateRequest {
string table = 1;
// record, JSON object
google.protobuf.Struct record = 2;
}
message UpdateResponse {
}
message DeleteRequest {
string table = 1;
// id or ids, eg. 'user-1', or comma separated ids 'user-1,user-2'
string id = 2;
}
message DeleteResponse {
}
message TruncateRequest {
string table = 1;
}
message TruncateResponse {
string table = 1;
}