【发布时间】:2019-06-03 16:50:09
【问题描述】:
我最近从 Falcor 0.x 升级到 1.1.0(下一步将是 2.x)
根据Falcor migration documentation,在调用model.get 时,引用不再作为json 发出。
不过,我想知道在 model.get 中管理引用的最佳做法是什么。
这是一个例子。
具有以下 json 图:
{
jsonGraph: {
comment: {
123: {
owner: { $type: "ref", value: ["user", "abc"] },
message: "Foo"
}
},
user: {
abc: {
name: "John Doe"
initials: "JD"
}
}
}
}
调用model.get 将导致:
const json = await model.get(["comment", "123", ["owner", "message"]);
{
owner: undefined, // 0.x was returning `["user", "abc"]`
message: "John Doe"
}
但也有可能只获得所有者:
const json = await model.get(["comment", "123", "owner", ["name", "initials"]);
{
name: "John Doe",
initials: "JD"
}
在model.get 中处理引用的建议是什么?
我应该手动获取所有者(就像最后一个示例一样?)还是应该在 comment 模型中使用 ownerId 而不是 owner 引用?
【问题讨论】:
标签: falcor falcor-router