返回数据&来自falcor路由器的参考

时间:2015-10-02 18:43:18

标签: falcor falcor-router

我有一条路线可以返回有关用户帐户功能的详细信息:

// games[{keys:games}].features[{integers:indices}]
{
    $type : "atom",
    value : {
        id: "6",
        count: "1",
        ...
    }
}

还有一条路线可以返回有关特定功能的一般细节:

// features[{integers:features}]
{
    $type : "atom",
    value : {
        name : "fooga",
        max : 10,
        ...
    }
}

我不想将通用功能数据合并到用户特定数据中,因为这将是一堆数据重复,但我也希望能够在一个请求中完成所有这些

构建路线/返回数据的智能方法是什么,以便games[{keys:games}].features[{integers:indices}]可以返回features[{integers:features}]的有用参考?

我尝试将它们分开:

// games[{keys:games}].features[{integers:indices}].details
{
    $type : "atom",
    value : {
        id: "6",
        count: "1",
        ...
    }
}

// games[{keys:games}].features[{integers:indices}].meta
{
    $type : "ref",
    value : [
        "features",
        "15"
    ]
}

但我无法找到解决.meta引用的方法,无需编写像...features.0.meta.[name,max,...]这样的冗余看似路径。理想情况下,ref只返回一个原子,因为它只是一小部分数据。

1 个答案:

答案 0 :(得分:0)

我最终像这样构建它:

games[{keys:games}].features[{integers:indices}].details
games[{keys:games}].features[{integers:indices}].feature
features[{keys:games}][{integers:features}].details

丑陋的道路,但是¯\ _(ツ)_ /¯

相关问题