Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] ORM Integration #429

Closed
danforbes opened this issue Jul 8, 2017 · 4 comments
Closed

[Question] ORM Integration #429

danforbes opened this issue Jul 8, 2017 · 4 comments
Labels

Comments

@danforbes
Copy link

Does grpc-gateway integrate with any ORMs, such as go-pg? For instance, is it possible to annotate a protobuf message with an option to specify SQL-specific properties on the generated Go model? If not, is this the sort of thing that the maintainers would consider accepting a pull request for?

@tamalsaha
Copy link
Collaborator

tamalsaha commented Jul 8, 2017

Does grpc-gateway integrate with any ORMs, such as go-pg?

No.

For instance, is it possible to annotate a protobuf message with an option to specify SQL-specific properties on the generated Go model?

Yes. https://developers.google.com/protocol-buffers/docs/proto#extensions . You don't need any special support or dependency on this project. Define your field level proto extensions, then write your glue code to use some ORM layer.

@yugui yugui added the question label Jul 8, 2017
@yugui
Copy link
Member

yugui commented Jul 8, 2017

I guess @danforbes is talking about something like golang/protobuf#52.
https://github.com/favadi/protoc-go-inject-tag in particular.

And as @tamalsaha said, it does not need any special support in this project.

@tamalsaha
Copy link
Collaborator

tamalsaha commented Jul 8, 2017

Thank @yugui . I did not know about this injector thing. But this is probably never going to be supported by the official protobuf team.

I was talking more about field level annotations like http://godoc.org/github.com/gogo/protobuf/gogoproto

message A {
		optional string Description = 1 [(gogoproto.nullable) = false];
		optional int64 Number = 2 [(gogoproto.nullable) = false];
		optional bytes Id = 3 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uuid", (gogoproto.nullable) = false];
	}

ref: https://github.com/gogo/protobuf/blob/master/extensions.md

I would think it will be possible to take those annotations and then call some ORM code in some glue code.

@danforbes
Copy link
Author

Cool, thanks for the insights, guys! I'll look into your suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants