Permalink
Browse files

fix fetching of the documents

  • Loading branch information...
1 parent d852b90 commit 2ee43691670ac6b545936403e1d6d8622dcf184c @petrjanda committed Apr 27, 2012
@@ -67,8 +67,8 @@ CouchRepository.prototype.storeEvent = function(aggregateId, name, attrs, callba
*/
CouchRepository.prototype.getEventsByAggregate = function(aggregateId, callback) {
var self = this,
- startKey = '["' + aggregateId + '",0]',
- endKey = '["' + aggregateId + '",9999999999999]',
+ startKey = '["' + aggregateId + '","0"]',
+ endKey = '["' + aggregateId + '","9999999999999999"]',
params = '?startkey=' + startKey + '&endkey=' + endKey;
this.start = new Date().getTime();
@@ -93,8 +93,8 @@ CouchRepository.prototype.getEventsByName = function(type, from, callback) {
// Load function itself called once or multiple times.
var load = function(type, callback) {
- var startKey = '["' + type + '",' + from + ']',
- endKey = '["' + type + '",9999999999999]',
+ var startKey = '["' + type + '","' + from + '"]',
+ endKey = '["' + type + '","9999999999999999"]',
params = '?startkey=' + startKey + '&endkey=' + endKey;
self.start = new Date().getTime();
@@ -81,7 +81,7 @@ CouchStorage.prototype.loadView = function(id, callback) {
CouchStorage.prototype._loadBareView = function(id, callback) {
this.request({
method: 'GET',
- path: '/' + this.database + '/_design/cqrs/_view/viewSnapshot?startkey=["' + id + '",999999999999999999]&endkey=["' + id + '",0]&limit=1&descending=true'
+ path: '/' + this.database + '/_design/cqrs/_view/viewSnapshot?startkey=["' + id + '","999999999999999999"]&endkey=["' + id + '","0"]&limit=1&descending=true'
}, function(data) {
data = JSON.parse(data);
View
@@ -1,6 +1,11 @@
var http = require('http'),
nano = require('nano');
+/*
+ * Whole class would be replaced by nano!
+ * @depricated
+ */
+
module.exports = CouchDb = function(options) {
options = options || {};
@@ -76,7 +76,7 @@ describe('CouchRepository', function() {
expect(couchdb.request).toHaveBeenCalledWith({
method : 'GET',
- path : '/cqrs/_design/cqrs/_view/aggregate?startkey=["1",0]&endkey=["1",9999999999999]'
+ path : '/cqrs/_design/cqrs/_view/aggregate?startkey=["1","0"]&endkey=["1","9999999999999999"]'
}, jasmine.any(Function));
})
@@ -105,7 +105,7 @@ describe('CouchRepository', function() {
expect(couchdb.request).toHaveBeenCalledWith({
method: 'GET',
- path: '/cqrs/_design/cqrs/_view/name?startkey=["foo",1000]&endkey=["foo",9999999999999]'
+ path: '/cqrs/_design/cqrs/_view/name?startkey=["foo","1000"]&endkey=["foo","9999999999999999"]'
}, jasmine.any(Function));
})
@@ -115,12 +115,12 @@ describe('CouchRepository', function() {
expect(couchdb.request).toHaveBeenCalledWith({
method: 'GET',
- path: '/cqrs/_design/cqrs/_view/name?startkey=["foo",0]&endkey=["foo",9999999999999]'
+ path: '/cqrs/_design/cqrs/_view/name?startkey=["foo","0"]&endkey=["foo","9999999999999999"]'
}, jasmine.any(Function));
expect(couchdb.request).toHaveBeenCalledWith({
method: 'GET',
- path: '/cqrs/_design/cqrs/_view/name?startkey=["bar",0]&endkey=["bar",9999999999999]'
+ path: '/cqrs/_design/cqrs/_view/name?startkey=["bar","0"]&endkey=["bar","9999999999999999"]'
}, jasmine.any(Function));
})
@@ -37,7 +37,7 @@ describe('CouchStorage', function() {
}
function viewPath(id) {
- return '/cqrs/_design/cqrs/_view/viewSnapshot?startkey=["' + id + '",999999999999999999]&endkey=["' + id + '",0]&limit=1&descending=true'
+ return '/cqrs/_design/cqrs/_view/viewSnapshot?startkey=["' + id + '","999999999999999999"]&endkey=["' + id + '","0"]&limit=1&descending=true'
}
beforeEach(function() {

0 comments on commit 2ee4369

Please sign in to comment.