forked from infobloxopen/protoc-gen-gorm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.proto
107 lines (97 loc) · 3.01 KB
/
user.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
syntax = "proto3";
// Designed to mimic the behavior shown in the GORM example at
// http://doc.gorm.io/models.html
package user;
import "google/protobuf/timestamp.proto";
import "atlas/rpc/resource/v1/resource.proto";
import "options/gorm.proto";
option go_package = "github.com/infobloxopen/protoc-gen-gorm/example/user;user";
message User {
option (gorm.opts) = {
ormable: true,
multi_account: true
};
atlas.resource.v1.Identifier id = 1
[(gorm.field).tag = { type: "uuid" primary_key: true }];
google.protobuf.Timestamp created_at = 2;
google.protobuf.Timestamp updated_at = 3;
google.protobuf.Timestamp birthday = 4;
uint32 age = 5 [(gorm.field).drop = true]; // synthetic field
uint32 num = 6;
CreditCard credit_card = 7; // has one
repeated Email emails = 8; // has many
repeated Task tasks = 9 [(gorm.field).has_many = {
position_field: "priority"
foreignkey_tag: { not_null: true }
}];
Address billing_address = 10 [(gorm.field).belongs_to = {}];
Address shipping_address = 11 [(gorm.field).belongs_to = {}];
repeated Language languages = 12 [(gorm.field).many_to_many = {}];
repeated User friends = 13 [(gorm.field).many_to_many = {}];
atlas.resource.v1.Identifier shipping_address_id = 14;
atlas.resource.v1.Identifier external_uuid = 15
[(gorm.field).tag = { type: "uuid" }];
}
message Email {
option (gorm.opts) = {
ormable: true,
multi_account: true
};
atlas.resource.v1.Identifier id = 1
[(gorm.field).tag = { type: "uuid" primary_key: true }];
string email = 2;
bool subscribed = 3;
atlas.resource.v1.Identifier user_id = 4;
atlas.resource.v1.Identifier external_not_null = 5
[(gorm.field).tag = { type: "uuid" not_null: true }];
}
message Address {
option (gorm.opts) = {
ormable: true,
multi_account: true
};
atlas.resource.v1.Identifier id = 1
[(gorm.field).tag = { type: "integer" primary_key: true }];
string address_1 = 2;
string address_2 = 3;
string post = 4;
atlas.resource.v1.Identifier external = 5
[(gorm.field).tag = { type: "jsonb" }];
atlas.resource.v1.Identifier implicit_fk = 6 [(gorm.field) = {
reference_of: "Email"
tag: { type: "text" }
}];
}
message Language {
option (gorm.opts) = {
ormable: true,
multi_account: true
};
atlas.resource.v1.Identifier id = 1
[(gorm.field).tag = { type: "integer" primary_key: true }];
string name = 2;
string code = 3;
atlas.resource.v1.Identifier external_int = 4
[(gorm.field).tag = { type: "integer" }];
}
message CreditCard {
option (gorm.opts) = {
ormable: true,
multi_account: true
};
atlas.resource.v1.Identifier id = 1
[(gorm.field).tag = { type: "integer" primary_key: true }];
google.protobuf.Timestamp created_at = 2;
google.protobuf.Timestamp updated_at = 3;
string number = 4;
atlas.resource.v1.Identifier user_id = 5;
}
message Task {
option (gorm.opts) = {
ormable: true,
multi_account: true
};
string name = 1;
string description = 2;
int64 priority = 3;
}