[Falcor] Retrieving Multiple Values
In addition to being able to retrieve a path from a Falcor Model, you can also retrieve multiple Path Sets. Path Sets are paths that contain ranges or multiple string keys inside of indexers. In addition to being able to retrieve a Path Set, you can also retrieve as many paths as you like in a single method call.
You can fetch range of data:
model.get('people[0..1].titles[0].name')
Because what you fetch is not just a single a value, you need to use:
model.get()
Which return you a json string.
SO for example:
<!-- index.html -->
<html>
<head>
<!-- Do _not_ rely on this URL in production. Use only during development. -->
<script src="//netflix.github.io/falcor/build/falcor.browser.js"></script>
<script>
var model = new falcor.Model({
cache: {
people: [
{
name: "ZT",
titles: [
{
id: 123,
name: "Senior Frontend developer",
rating: 10
}
]
},
{
name: "WO",
titles: [
{
id: 321,
name: "Senior Software Engineer",
rating: 10
}
]
}
]
}
}); model.get('people[0..1].titles[0].name')
.then(function (json){
console.log(JSON.stringify(json, null, 2));
});
</script>
</head>
<body>
</body>
</html>
And what you will get:
{
"json": {
"people": {
"0": {
"titles": {
"0": {
"name": "Senior Frontend developer"
}
}
},
"1": {
"titles": {
"0": {
"name": "Senior Software Engineer"
}
}
}
}
}
}
You can pass multi enter points:
model.get('people[0..1].titles[0].name', 'people[0..1].titles[0].rating')
So you will get :
{
"json": {
"people": {
"0": {
"titles": {
"0": {
"name": "Senior Frontend developer",
"rating": 10
}
}
},
"1": {
"titles": {
"0": {
"name": "Senior Software Engineer",
"rating": 8
}
}
}
}
}
}
Notice that:
model.get('people[0..1].titles[0].name',
'people[0..1].titles[0].rating')
The entor points we pass in are quite simialr, actually we can group them:
model.get('people[0..1].titles[0]["name", "rating"]')
You will still get the same result.
[Falcor] Retrieving Multiple Values的更多相关文章
- [Go] Returning Multiple Values from a Function in Go
Returning multiple values from a function is a common idiom in Go, most often used for returning val ...
- python报错 TypeError: a() got multiple values for argument 'name'
[问题现象] 在一次调用修饰函数中出现了问题,折腾了一下午,一直报错 TypeError: got multiple values for argument 只是很简单的调用 from tsu2Ru ...
- Coroutines in Android - One Shot and Multiple Values
Coroutines in Android - One Shot and Multiple Values 在Android中, 我们用到的数据有可能是一次性的, 也有可能是需要多个值的. 本文介绍An ...
- reverse/inverse a mapping but with multiple values for each key
reverse/inverse a mapping but with multiple values for each key multi mappping dictionary , reverse/ ...
- 跨域:The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed
https://blog.csdn.net/q646926099/article/details/79082204 使用Ajax跨域请求资源,Nginx作为代理,出现:The 'Access-Cont ...
- 跨域The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.解决方案
使用Ajax跨域请求资源,Nginx作为代理,出现:The 'Access-Control-Allow-Origin' header contains multiple values '*, *', ...
- 【问题解决】'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.
问题复述 今天项目组有人找我说之前部署的程序在测试环境没问题,到生产环境出现了奇怪的问题,点按钮没反应. 我通过腾讯会议发现他们的浏览器控制台上打出了如下错误: Access to XMLHttpRe ...
- TypeError: test() got multiple values for keyword argument 'key'
原因是: 1.函数调用的最终形式只会调用两个函数.一个list参数和一个dict参数,格式为call(func, list, dict); 2.如果传入参数中有key参数,那么首先key参数(包括扩展 ...
- Python TypeError: __init__() got multiple values for argument 'master'(转)
转自:https://stackoverflow.com/questions/33153404/python-typeerror-init-got-multiple-values-for-argume ...
随机推荐
- POJ 2230 (欧拉路)
分析: 基础的欧拉路算法,变化在于要求每条边正向和反向各走一遍. 链式前向星构图,只要标记走过的单向边,边找边输出即可. code #include <iostream> #include ...
- HDU 4632 CF 245H 区间DP(回文)
先说HDU 4632这道题,因为比较简单,题意就是给你一个字符串,然后给你一个区间,叫你输出区间内所有的回文子序列,注意是回文子序列,不是回文字串. 用dp[i][j]表示区间[i,j]内的回文子序列 ...
- sql批量插入数据之存储过程
-- ============================================= -- Author: jf_ou -- Create date: 2016/03/22 -- Desc ...
- 织梦安装过后出现"...www/include/templets/default/index.htm Not Found!"
在织梦网站搬家之后再整站更新,往往会遇到访问首页的时候出现www/include/templets/default/index.htm Not Found!,这个问题我遇到过两次,都是这样解决的: 进 ...
- excel设置单元格不可编辑
把允许编辑的单元格选定,右键-设置单元格格式-保护,把锁定前的对钩去掉.再点工具-保护工作表.这样就可以只让你刚才设定的单元格允许编辑,其他不允许.
- Destoon QQ互联一键登录审核不通过的解决方案
在QQ互联上申请帐号之后提交了审核, 后台填写APPID和KEY之后自己申请的QQ号可以正常登录,但QQ互联审核的时候一直审核不通过说是“您的网站审核未通过,原因是“点击QQ登录按钮提示登录失败或出现 ...
- MYSQL管理之主从同步管理 转载
MYSQL主从同步架构是目前使用最多的数据库架构之一,尤其是负载比较大的网站,因此对于主从同步的管理也就显得非常重要,新手往往在出现主从同步错误的时候不知道如何入手,这篇文章就是根据自己的经验来详细叙 ...
- 代码发布架构方案(SVN)
问题: 安装优化软件环境nginx,lvs 程序代码(不断更新) 配置更新(不断变更) 1.SVN介绍 1.1 什么是SVN(Subversion)? SVN(Subversion) ...
- 一、UITableView的属性
一.UITableView的属性 NSIndexPath类型是用来获取用户选择的indexPath,在别的函数里面,若需要知道用户选择了哪个cell,用上它可以省事很多.不必再去建全局变量sectio ...
- kd树的构建以及搜索
构建算法 k-d树是一个二叉树,每个节点表示一个空间范围.表1给出的是k-d树每个节点中主要包含的数据结构. 表1 k-d树中每个节点的数据类型 域名 数据类型 描述 Node-data 数据矢量 数 ...