On Thu, Feb 25, 2016 at 5:57 AM, Tim Richardson <t...@rewire.it> wrote:

> Hi, just wanted to check my declaration with you guys, is it possible to
> reuse the `Study` declaration in the `Denormalised`
>
You can define a field with type 'Study' without declaring it again in
'Denomalised'. Likewise, you don't need to declare TechnologyType multiple
times if they have the same definition. When declaring message fields, you
can reference any type defined anywhere in the same .proto file or in the
imported .proto files. For example:

package mypackage;

message Foo {  // Foo #1
  optional int32 value = 1;
}
message Bar {
  optional Foo foo1 = 1;  // This references the first Foo #1.
  optional Baz.Foo foo2 = 2;  // This reference the Foo #2 defined inside
Baz.
}
message Baz {
  message Foo {  // Foo #2
    optional string description = 1;
  }
}


>
> package mypackage;
>
>
> message Dataset {
>   required string accession = 1;
>   required string url_self = 2;
>   optional string title = 3;
>   optional string description = 4;
>   repeated TechnologyType technology = 5;
>   optional int32 samples = 6;
>   optional string type = 7;
>   repeated StudyId studies = 8;
>
>
>   message StudyId {
>     required string accession = 1;
>   }
>   message TechnologyType {
>     required string type = 1;
>   }
> }
>
>
> message Study {
>   required string accession = 1;
>   required string url_self = 2;
>   optional string title = 3;
>   optional string description = 4;
>   optional string alternative_stable_id = 5;
>   repeated StudyType type = 6;
>   repeated DatasetId datasets = 7;
>
>
>   message DatasetId {
>     required string accession = 1;
>   }
>   message StudyType {
>     required string type = 1;
>   }
> }
>
>
> message Denormalised {
>   required string accession = 1;
>   required string url_self = 2;
>   required string title = 3;
>   required string description = 4;
>   repeated TechnologyType technology = 5;
>   optional int32 samples = 6;
>   optional string type = 7;
>   repeated Study studies = 8; // do I have to redeclare Study
>
>
>   message TechnologyType {
>     required string type = 1;
>   }
> }
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to