1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
[
{
"_type": "_schemaType",
"name": "ArrayView",
"schema": {
"type": "object",
"extends": "View",
"properties": {
"arrayProp": { "type": "array" }
}
}
},
{
"_type": "Reduce",
"sourceType": "Human",
"sourceKeyName": "lastName",
"targetType": "ArrayView",
"add": " \
function add(key, previous, value) { \
if (!previous) previous = { firstNames: [] } \
previous.firstNames.push(value.firstName); \
return previous; \
} ",
"subtract": " \
function subtract(key, previous, value) { \
var idx; \
if ((idx = previous.firstNames.indexOf(value.firstName)) >= 0) \
previous.firstNames.splice(idx, 1); \
return previous; \
} "
},
{
"_type": "Human",
"firstName": "Bob",
"lastName": "Smith"
},
{
"_type": "Human",
"firstName": "Hank",
"lastName": "Jones"
},
{
"_type": "Human",
"firstName": "Roger",
"lastName": "Smith"
},
{
"_type": "Human",
"firstName": "Julio",
"lastName": "Jones"
}
]
|