0
我在MongoDB中有一個文檔,其中包含子文檔destinations
作爲字段。我想將這些數據返回給我的Jade模板,但是,這似乎並不奏效。將所有子目錄返回到Jade模板
用戶文檔:
{ _id: 582c7a1c60cd0447daa64b5e,
firstName: 'a',
lastName: 'a',
username: '[email protected]',
homeAirport: 'syd',
__v: 7,
destinations:
[ { airport: 'rhys', month: 'rhys', _id: 5837165c87373103f13921f9 },
{ airport: 'bob', month: 'bob', _id: 583716ae79f2e80498aa33ef },
{ airport: 'check',
month: 'ceck',
_id: 583716d4ba757104b0fcc8dd }
玉模板
if (user)
include addDestinations.jade
p The email address is #{user.username}
p My first name is #{user.firstName}
p My last name is #{user.lastName}
p I fly from #{user.homeAirport}
p I wanna go to #{user.destinations.aiport}
a(href='/logout') Log out
div
- console.log(user)
div
我怎麼叫SUBDOCS,並通過它的結果迭代渲染成html?
感謝iKoala,這是有道理的。我剛剛更新了答案,包括正確的語法 –
好的捕獲,我忘了那:) – iKoala