summaryrefslogtreecommitdiffstats
path: root/tests/auto/daemon/json/map-join-sourceuuids.json
blob: 24ad24e7036618633a56736bf098d3e77f849f5d (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
[
  {
    "_type": "_schemaType",
    "name": "MagicView",
      "schema": {
          "type": "object",
          "extends": "View",
          "properties": {
              "key": {
                  "type": "string"
              },
              "foo": {
                  "type": "string"
              },
              "bar": {
                  "type": "string"
              }
          }
      }
  },
  {
    "_type": "_schemaType",
    "name": "Foo",
    "schema": {
      "type": "object",
      "properties": {
        "magic": {
          "type": "string",
          "indexed": true
        }
      }
    }
  },
  {
    "_type": "_schemaType",
    "name": "Bar",
    "schema": {
      "type": "object",
      "extends": "Foo"
    }
  },
  {
    "_type": "Map",
    "targetType": "MagicView",
    "join": {
    "Foo": " \
      function map(obj, context) { \
        var foo, bar; \
        foo = obj; \
        if (!context) { \
          // callback to the Bar function below with foo as the context \
          jsondb.lookup({'index':'magic', 'value':foo.magic, 'objectType': 'Bar'}, foo); \
        } else { \
          bar = context; \
          jsondb.emit({ key: foo.magic, foo: foo._uuid, bar: bar._uuid, barExtra: bar.extra }); \
       } \
     } ",
    "Bar": " \
      function map(obj, context) { \
        var foo, bar; \
        bar = obj; \
        if (!context) { \
          // callback to the Foo function above with bar as the context \
          jsondb.lookup({'index':'magic', 'value':bar.magic, 'objectType': 'Foo'}, bar); \
        } else { \
          foo = context; \
          jsondb.emit({ key: foo.magic, foo: foo._uuid, bar: bar._uuid, barExtra: bar.extra }); \
       } \
    } "
}
  },
  {
    "_type": "Bar",
    "magic": "xyzzy"
  },
  {
    "_type": "Foo",
    "magic": "xyzzy"
  }
]