수신처 매개 변수 중 하나가 오는 문서의 값에 의해 결정되는 경로의 waitOn
부분을 구성하는 데 문제가 있습니다. 다른 구독에서.Iron Router를 사용하여 다른 구독에서 가져온 문서의 데이터에 종속적 인 구독
재생중인 컬렉션은 후보자 및 인터뷰입니다. 인터뷰에는 단 하나의 후보자가 있습니다. 다음은 몇 가지 샘플 데이터입니다.
candidate = {
_id: 1
firstName: 'Some',
lastName: 'Developer'
//other props
};
interview = {
_id: 1,
candidateId: 1
//other props
};
경로는 다음과 같이 구성됩니다.
this.route('conductInterview', {
path: '/interviews/:_id/conduct', //:_id is the interviewId
waitOn: function() {
return [
Meteor.subscribe('allUsers'),
Meteor.subscribe('singleInterview', this.params._id),
// don't know the candidateId to lookup because it's stored
// in the interview doc
Meteor.subscribe('singleCandidate', ???),
Meteor.subscribe('questions'),
Meteor.subscribe('allUsers')
];
},
data: function() {
var interview = Interviews.findOne(this.params._id);
return {
interview: interview,
candidate: Candidates.findOne(interview.candidateId);
};
}
});
문제
내가이 인터뷰 문서에 저장되어 있기 때문에waitOn
방법에
singleCandidate
가입에 전달할 candidateId이없는 것입니다.
나는 두 가지 가능한 해결책을 생각해 냈지만, 나는 그 중 어느 쪽도 정말로 좋아하지 않습니다. 첫 번째는 /interviews/:_id/:candidateId/conduct
과 같은 경로로 변경하는 것입니다. 두 번째는 데이터를 비정규 화하고 인터뷰 문서에 응시자의 정보를 저장하는 것입니다.
두 가지 외에도 다른 옵션이 있습니까?
뜨아 ... 너무 간단합니다. 나는이 숲에서 나무 숲을 볼 수 없었다. 'singleCandidate' 출판물을 다른 곳에서 사용하고 있습니다 만,'interviewCandidate' 출판물을 추가 할 것입니다. 감사! –