Skip to content

Protobuff compiler (protoc) plugin to generate CRUD enabling interfaces and implementations in the Go language.

License

Notifications You must be signed in to change notification settings

samlitowitz/protoc-gen-crud

Repository files navigation

Protobuf Annotations

Go Report Card Go Reference .github/workflows/pipes.yaml

Protobuff compiler (protoc) plugin to generate CRUD enabling interfaces and implementations in the Go language.

Table of Contents

  1. Installation
  2. Usage
  3. Feature Support
    1. Message
      1. Operations
      2. Delete Strategy
      3. Partial Creates/Updates
      4. Meta-Data
      5. Audit Logging
    2. Field
      1. Unique Identifiers
      2. Auto-generate Strategy
      3. Nullable
      4. Non-scalar Fields
        1. Relationships
          1. Unidirectional
          2. Bidirectional
    3. References

Installation

go install github.com/samlitowitz/protoc-gen-crud/cmd/protoc-gen-go-crud@latest

The protoc-gen-go-crud plugin depends on types generated by the protoc-gen-go plugin.

Usage

Ensure the protoc-gen-go-crud binary is in your path. As with all protoc plugins the go-crud suffix is the prefix for arguments passed to protoc, i.e. protoc --go-crud_out=path/to/out path/to/file.proto. The protoc-gen-go-crud plugin generates an implementation agnostic source file suffixed .pb.crud.go and an implementation specific source file suffixed .pb.crud.<implementation.go for each implementation.

Example proto files can be found in the test-cases directory.

The protoc-gen-go-crud plugin depends on types generated by the protoc-gen-go plugin.

Feature Support

Items with a check mark have been implemented Items without a check mark have not been implemented but are planned for implementation.

Message

Operations

Implementation Create Read Update Delete
SQLite
PgSQL

Delete Strategy

Implementation Hard Soft
SQLite
PgSQL

Partial Creates/Updates

Implementation Field Mask
SQLite
PgSQL

Row Meta-Data

Implementation Created At Updated At Deleted At
SQLite
PgSQL

Audit Logging

Implementation Implemented
SQLite
PgSQL

Field

Unique Identifiers

Implementation Single Composite
SQLite
PgSQL

As Timestamp

Implementation google.protobuf.Timestamp
SQLite
PgSQL

Auto-generate Strategy

Implementation None UUID Sequential Integer
SQLite
PgSQL

Nullable

Implementation Nullable Not-Nullable
SQLite
PgSQL

Non-scalar Fields

Implementation Skip Inline Relationship (see below)
SQLite -
PgSQL -

Relationships

Unidirectional
Implementation One-to-one One-to-many Many-to-many
SQLite
PgSQL
Bidirectional
Implementation One-to-one One-to-many Many-to-many
SQLite
PgSQL

References

  1. https://go.dev/blog/protobuf-apiv2
  2. https://golang.design/research/generic-option/
  3. https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html
  4. https://github.com/googleapis/googleapis/blob/master/google/api/http.proto
  5. https://github.com/grpc-ecosystem/grpc-gateway/tree/main/protoc-gen-openapiv2/options
  6. https://go.dev/blog/intro-generics
  7. https://pkg.go.dev/modernc.org/sqlite

About

Protobuff compiler (protoc) plugin to generate CRUD enabling interfaces and implementations in the Go language.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages