summaryrefslogtreecommitdiffstats
path: root/tests/auto/partition/json/reduce-subprop.json
blob: a5002853f7ffc6950d894b9f4e267d259ffc4f39 (plain)
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
53
54
55
56
57
58
[
  {
    "_type": "Contact",
    "displayName": "Joe Smith",
    "name": {
      "firstName": "joe",
      "lastName": "smith"
    }
  },
  {
    "_type": "Contact",
    "displayName": "Nancy Doe",
    "name": {
      "firstName": "nancy",
      "lastName": "doe"
    }
  },
  {
    "_type": "Contact",
    "displayName": "Nancy Doe",
    "name": {
      "firstName": "joe",
      "lastName": "harrison"
    }
  },
  {
    "_type": "Contact",
    "displayName": "Nancy Doe",
    "name": {
      "firstName": "nancy",
      "lastName": "williams"
    }
  },
  {
    "_type": "Contact",
    "displayName": "Nancy Doe",
    "name": {
      "firstName": "doug",
      "lastName": "johnson"
    }
  },
  {
    "_type": "_schemaType",
    "name": "NameCount",
    "schema": {
      "type": "object",
      "extends": "View"
    }
  },
  {
    "_type": "Reduce",
    "targetType": "NameCount",
    "sourceType": "Contact",
    "sourceKeyName": "name.firstName",
    "add": "function add (k, z, c) { if (!z) { z = { count: 0 } }; z.count += 1; return z;}",
    "subtract": "function subtract (k, z, c) { if (!z) {z = {count: 0}}; z.count -= 1; if (z.count) return z;}"
  }
]