{{#each alliances}}
{{this.ally_id}} // HOW TO CHECK IF THIS
{{#each requestSent}}
<li>
<strong>{{this.title}}</strong>
<a href="/join-alliance/{{this.title}}" class="btn btn-success">Join</a>
{{this._id}} // IS EQUAL TO THIS
</li>
{{/each}}
{{/each}}
{{/if}}
嘿,我需要写if语句,并检查第一个ally_id
中的each
是否等于第二个this._id
中的each
。有可能吗?我正在考虑使用jQuery,如果找不到其他解决方案。我需要这样做,因为如果这些ID's
匹配,那么我将更改显示join
的按钮
这是合计:
AllianceMemberRequest.aggregate([
//{"$match": {"ally_id": ObjectId(alliance._id)}},
{"$lookup": {
"from": "alliances",
"localField": "ally_id",
"foreignField": "_id",
"as": "requestSent"
}}
])