2017-05-06 2 views
0

프로토콜 버퍼 주위에 머리를 쓰려고합니다. 나는 기본적인 것들을 이해했지만, 이제 다음 자바 스크립트 객체를 .proto로 정의하려고합니다. Node.js gRPC Library프로토콜 버퍼

const listsSchema = new Schema({ 
    id: { type: String, required: true }, 
    id_str: { type: String, required: true, index: { unique: true } }, 
    name: { type: String, required: true }, 
    description: { type: String, required: true }, 
    slug: { type: String, required: true }, 
    createdAt: { type: Date, 'default': Date.now }, 
    updatedAt: { type: Date, 'default': Date.now }, 
    track: { type: Boolean, 'default': false }, 
    lastTrackedTweet: [ 
    { 
     id: { type: String, required: true }, 
     id_str: { type: String, required: true }, 
     createdAt: { type: Date, 'default': Date.now }, 
     updatedAt: { type: Date, 'default': Date.now } 
     } 
    ] 
}); 

이를 사용하면 내가 들고 오지 않은,하지만 거부지고있는 것이다.

syntax = "proto3"; 

package lists; 

service Lists { 
    rpc FindLists (ListRequest) returns (ListReply) {} 
} 

message ListRequest { 
    struct params = 1; 
} 

message ListReply { 
    repeated struct List = 1; 
} 

message List { 
int64 id = 1; 
string id_str = 2; 
string name = 3; 
string description = 4; 
string slug = 5; 
Timestamp createdAt = 6; 
Timestamp updatedAt = 7; 
bool track = 8; 
repeated struct LastTrackedTweet = 9; 
} 

message LastTrackedTweet { 
    int64 id = 1; 
    string id_str = 2; 
    Timestamp createdAt = 3; 
    Timestamp updatedAt = 4; 
} 

답변

0

알아 냈습니다. 고급 예제에서는 설명서가 좋지 않습니다.

syntax = "proto3"; 

package lists; 

service Lists { 
    rpc FindLists (ListRequest) returns (ListReply) {} 
} 

message ListRequest { 
string query = 1 
} 

message ListReply { 
    repeated List list = 1; 
} 

message List { 
int64 id = 1; 
string id_str = 2; 
string name = 3; 
string description = 4; 
string slug = 5; 
string createdAt = 6; 
string updatedAt = 7; 
bool track = 8; 
repeated LastTrackedTweet lastTrackedTweet = 9; 
} 

message LastTrackedTweet { 
    int64 id = 1; 
    string id_str = 2; 
    string createdAt = 3; 
    string updatedAt = 4; 
}