Created
September 25, 2010 23:47
-
-
Save NeilRobbins/597428 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "_id": "_design/eventsource", | |
| "_rev": "10-6871125abf6ffb2c2b34a43e08c9909c", | |
| "language": "javascript", | |
| "views": { | |
| "allEvents": { | |
| "map": "function(doc) { if (doc.Events) {doc.Events.forEach(function(e) { if (e.Event.Detail.AggregateId) { emit(e.Event.Detail.AggregateId, e.Event); }}); }}" | |
| } | |
| }, | |
| "filters": { | |
| "eventsByType": "function(doc, req) { if (doc.Events) { doc.Events.forEach(function(e) {if (e.Event) {if (e.Event.Meta) {if (e.Event.Meta.Type == req.query.type) {return true;}}}});return false;}}" | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "_id": "a4f089ed-be93-4505-b7fc-91932f28cfea", | |
| "_rev": "1-68a8a520748e1a7d698104d02f03706a", | |
| "AggregateId": "fdc894e6-c15f-449c-b96e-9afc175e4129", | |
| "Events": [ | |
| { | |
| "Event": { | |
| "Meta": { | |
| "Type": "EventStore.Specifications.AggregateEvent" | |
| }, | |
| "Detail": { | |
| "AggregateId": "fdc894e6-c15f-449c-b96e-9afc175e4129" | |
| } | |
| } | |
| }, | |
| { | |
| "Event": { | |
| "Meta": { | |
| "Type": "EventStore.Specifications.AggregateEvent" | |
| }, | |
| "Detail": { | |
| "AggregateId": "fdc894e6-c15f-449c-b96e-9afc175e4129" | |
| } | |
| } | |
| } | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| UPDATE: A solution for my issue was provided by davisp on the couchdb irc channel. | |
| It involved replacing the filter function with one that worked! :) | |
| The return within the closure was not returning from the function, but was only returning from the closure. | |
| Thanks to davisp. | |
| The correct version of the function was posted by davisp here: | |
| http://friendpaste.com/2KnwyZYFxix9vf8F2BGkBU?rev=613861393137 | |
| If I call the _changes feed with the filter in the design document then I don't get any results, even when the request argument supplied should return them. | |
| So this: | |
| /_changes?filter=eventsource/eventsByType&Type="EventStore.Specifications.AggregateEvent" | |
| just return this: | |
| {"results":[ | |
| ], | |
| "last_seq":98} | |
| when I would expect a number of documents to be returned. | |
| Any suggestions appreciated. As would be any general comment on the javascript. | |
| Thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment