1
我和Falcor一起玩,看看我工作的公司是否可以使用它,所以我是一個新手。Falcor - 深層嵌套參考
我使用模型作爲數據源。
這是我的模型:
var model = new falcor.Model({
cache:{
currenciesById: {
"1": { code: "USD", format: "$" },
"2": { code: "GBP", format: "£" },
"3": { code: "EUR", format: "€" },
"4": { code: "YEN", format: "¥"}
},
validCurrencies: {
"1": { $type: "ref", value: ["currenciesById", 1] },
"2": { $type: "ref", value: ["currenciesById", 2] },
"3": { $type: "ref", value: ["currenciesById", 3] },
"4": { $type: "ref", value: ["currenciesById", 4] }
},
quotesByPart: {
"100" : {price: 1768.34, currency: { $type: "ref", value: ["currencyById", 1] }},
"200" : {price: 2834.44, currency: { $type: "ref", value: ["currencyById", 2] }},
"201" : {price: 7803.54, currency: { $type: "ref", value: ["currencyById", 3] }},
"347" : {price: 389.09, currency: { $type: "ref", value: ["currencyById", 4] }}
},
quotes: {
"1": { $type: "ref", value: ["quotesByPart", 100] },
"2": { $type: "ref", value: ["quotesByPart", 200] },
"307": { $type: "ref", value: ["quotesByPart", 347] }
},
reservedQuotes:{
"1": { $type: "ref", value: ["quotesByPart", 201] }
}
}
});
當我提出這個要求:
get('quotes[307].["price", "currency"]')
這是Falcor的迴應:
{
"json": {
"quotes": {
"307": {
"price": 389.09,
"currency": [
"currencyById",
4
]
}
}
}
}
這就是我expencting。 Falcor發現引號[307]實際上是對quotesByPart [347]的引用並解析它,實際上它會返回正確的價格和對貨幣的參考。
然後,我試圖讓Falcor解決同一個請求中的第二個參考 - 貨幣。 我試着寫這樣的要求:
get('quotes[307].["currency"].["code"]')
,或者出於絕望
get('quotes[307].["currency.code"]')
的,我不能讓Falcor解決第二個參考。
有人能告訴我我在這裏錯過了什麼嗎?
問題是'currencyById'應該是'currencyById'?好的,語法是用來獲得報價的'價格',還有'貨幣'的'代碼'和'格式'的語法是什麼?它是'get('quotes [307]。[「price」,「currency.code」,「currency.format」]')'? Falcor Paths的文件仍然缺乏...... – jordanb