[ { "_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" } ]