-
Notifications
You must be signed in to change notification settings - Fork 164
/
user.proto
110 lines (99 loc) · 3.66 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
108
109
110
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/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
multi_compartment: true
};
atlas.rpc.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 [(gorm.field).has_many = {disable_association_autocreate: true disable_association_autoupdate: true preload: true}]; // has many
repeated Task tasks = 9 [(gorm.field).has_many = {position_field: "priority" foreignkey_tag: {not_null: true} disable_association_autocreate: false}];
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.rpc.Identifier shipping_address_id = 14;
atlas.rpc.Identifier external_uuid = 15 [(gorm.field).tag = {type: "uuid"}];
Department department = 16;
}
message Email {
option (gorm.opts) = {
ormable: true,
multi_account: true
multi_compartment: true
};
atlas.rpc.Identifier id = 1 [(gorm.field).tag = {type: "uuid" primary_key: true}];
string email = 2;
bool subscribed = 3;
atlas.rpc.Identifier user_id = 4;
atlas.rpc.Identifier external_not_null = 5 [(gorm.field).tag = {type: "uuid" not_null: true}];
}
message Address {
option (gorm.opts) = {
ormable: true,
multi_account: true
multi_compartment: true
};
atlas.rpc.Identifier id = 1 [(gorm.field).tag = {type: "integer" primary_key: true}];
string address_1 = 2;
optional string address_2 = 3;
string post = 4;
atlas.rpc.Identifier external = 5 [(gorm.field).tag = {type: "jsonb"}];
atlas.rpc.Identifier implicit_fk = 6 [(gorm.field) = {reference_of: "Email" tag: {type: "text"} }];
}
message Language {
option (gorm.opts) = {
ormable: true,
multi_account: true
multi_compartment: true
};
atlas.rpc.Identifier id = 1 [(gorm.field).tag = {type: "integer" primary_key: true}];
string name = 2;
string code = 3;
atlas.rpc.Identifier external_int = 4 [(gorm.field).tag = {type: "integer"}];
}
message CreditCard {
option (gorm.opts) = {
ormable: true,
multi_account: true
multi_compartment: true
};
atlas.rpc.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.rpc.Identifier user_id = 5;
}
message Task {
option (gorm.opts) = {
ormable: true,
multi_account: true
multi_compartment: true
};
string name = 1;
string description = 2;
int64 priority = 3;
optional string id = 4;
}
// Department added example for composite primary keys
message Department {
option (gorm.opts) = {
ormable: true,
};
// department name and id are composite primary keys
string name = 1 [(gorm.field).tag = {primary_key: true}];
int64 id = 2 [(gorm.field).tag = {primary_key: true}];
}