Categorygithub.com/imran31415/proto-db-translator

# README

Proto-DB Translator

codecov

proto-db-translator is a Go library for generating and managing database schemas from protobuf definitions.

Installation

go get github.com/imran31415/proto-db-translator

The core purpose of this package is to provide translation logic of protobuf DB annotations into actual SQL statements and code models. The annotations are stored in a separate repo: https://github.com/imran31415/protobuf-db

  • /translator for the main code.
  • proto/*.proto shows example proto definitions leveraging the annotations
  • /generated_models for the example db models generated by the protobuf annotations
  • /generate_models for the code used to generate the DB code based on the protobuf bessages that are annotated.

Dependencies

npm install --save-dev ts-proto
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest

Usage:

To use DB annotations do the following:

  • Copy the db annotations submodule to a vendor file locally so you can use with your protobuf"

 git clone https://github.com/imran31415/protobuf-db.git protobuf-db

Run protoc referencing the path of the cloned repo --proto_path=./protobuf-db/proto \

export PATH=$PATH:$HOME/go/bin
protoc -I . \
       --plugin=protoc-gen-ts_proto=$(pwd)/node_modules/.bin/protoc-gen-ts_proto \
       --ts_proto_out=./ts_out \
       --ts_proto_opt=esModuleInterop=true,outputEncodeMethods=false,outputJsonMethods=false,outputClientImpl=false \
       --go_out=./ \
       --go-grpc_out=./ \
       --grpc-gateway_out=./ \
       --proto_path=./protobuf-db/proto \
       --proto_path=./proto \
       ./proto/role.proto \
       ./proto/role_hierarchy.proto \
       ./proto/invalid_schema.proto \
       ./proto/user.proto \
       ./proto/order_details.proto \
       ./proto/order.proto

Upgrade:

go get -u ./...

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
Package generated_models contains generated code for schema 'protodbtranslatortestdb'.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author