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

How to map the tag gorm:"column:id;primaryKey;auto" to [(gorm.field) = { ... }] #236

Open
TENX-S opened this issue Jul 25, 2022 · 0 comments

Comments

@TENX-S
Copy link

TENX-S commented Jul 25, 2022

I can't find relevant code in example:

message TypeWithID {
// Again we use the 'ormable' option, but also include an extra field
// using the 'include' option. Any number of fields can be defined this way
// to be visible on the ORM side, but hidden from the API. This is generally
// useful to aggregate values from the database into API fields
option (gorm.opts) = {
ormable: true,
include: [
{type: "int32", name: "secret_int", tag: {ignore: true}},
{type: "[]*JoinTable", name: "multi_account_types", tag: {foreignkey: "TypeWithIDID"}}
]
};
// any field named 'id' is assumed by gorm to be the primary key for the
// object.
uint32 id = 1;
// The field option also allows arbitrary tag setting, such as informing
// gorm of a primary key, different column names or different types in the db
string ip = 2 [(gorm.field) = {tag: {column: "ip_addr"}}];
// A default has-many relationship, will error on generation if no FK field,
// convention {typename}_id, is present. These FK fields will be automatically
// populated on create and update.
repeated TestTypes things = 3;
// A default has-one relationship, will error as above
TestTypes a_nested_object = 4;
// An in-package and cross-package imported type (in-package can use any
// association type, cross-package is limited to belongs_to and many_to_many)
example.IntPoint point = 5 [(gorm.field).belongs_to = {}];
user.User user = 6 [(gorm.field).belongs_to = {}];
gorm.types.InetValue address = 7;
repeated uint32 multiaccount_type_ids = 8 [(gorm.field).drop = true];
APIOnlyType synthetic_field = 9;
float tag_test = 10 [(gorm.field).tag = {type: "float" , precision: 6}];
string tag_size_test = 11 [(gorm.field).tag = {size: 512}];
google.protobuf.FloatValue float_field = 12;
google.protobuf.DoubleValue double_field = 13;
// Limited support for DB type 'time', implemented via strings (string -> DB && DB -> string)
gorm.types.TimeOnly time_only = 14;
google.protobuf.Timestamp deleted_at = 15;
}

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

No branches or pull requests

1 participant