I am trying to figure out how to integrate the gorm.Model fields (deleted_at, create_at, id, etc) into my proto3 definitions. However, I can't a datetime type for proto3. I tried looking for documentation on how to serialize the gorm fields to strings (since proto3 handles strings) but I have not found anything.
Has anyone been able to successfully use the gorm model fields in their proto definitions? I'm using go-micro's plugin to generate *pb.go files.
Here's my current message definition which doesn't work. It seems like empty strings are being stored in the database for deleted_at since when querying for deleted_at is null the postgres database returns nothing.
message DatabaseConfig {
string address = 1;
int32 port = 2;
string databaseName = 3;
string username = 4;
string password = 5;
string databaseType = 6;
string quertStatement = 7;
int32 id = 8;
string createdAt = 9;
string updatedAt = 10;
string deletedAt = 11;
}
UPDATE: I've updated my proto def to the following but gorm still isn't properly using the Id, CreatedAt, UpdatedAt, and DeletedAt fields
syntax = "proto3";
package go.micro.srv.importer;
import "google/protobuf/timestamp.proto";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service ImporterService {
rpc CreateDatabaseConfig(DatabaseConfig) returns (Response) {}
rpc RetrieveDatabaseConfig(GetRequest) returns (Response) {}
rpc UpdateDatabaseConfig(DatabaseConfig) returns (Response) {}
rpc DeleteDatabaseConfig(DatabaseConfig) returns (Response) {}
}
message GetRequest {}
message DatabaseConfig {
string address = 1;
int32 port = 2;
string databaseName = 3;
string username = 4;
string password = 5;
string databaseType = 6;
string quertStatement = 7;
int32 id = 8;
google.protobuf.Timestamp createdAt = 9 [(gogoproto.stdtime) = true];
google.protobuf.Timestamp updatedAt = 10 [(gogoproto.stdtime) = true];
google.protobuf.Timestamp deletedAt = 11 [(gogoproto.stdtime) = true];
}
message Response {
bool created = 1;
DatabaseConfig database_config = 2;
repeated DatabaseConfig databaseConfigs = 3;
}