Skip to content

Commit

Permalink
fix fetching of the documents
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Janda committed Apr 27, 2012
1 parent d852b90 commit 2ee4369
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/repository/couchRepository.js
Expand Up @@ -67,8 +67,8 @@ CouchRepository.prototype.storeEvent = function(aggregateId, name, attrs, callba
*/ */
CouchRepository.prototype.getEventsByAggregate = function(aggregateId, callback) { CouchRepository.prototype.getEventsByAggregate = function(aggregateId, callback) {
var self = this, var self = this,
startKey = '["' + aggregateId + '",0]', startKey = '["' + aggregateId + '","0"]',
endKey = '["' + aggregateId + '",9999999999999]', endKey = '["' + aggregateId + '","9999999999999999"]',
params = '?startkey=' + startKey + '&endkey=' + endKey; params = '?startkey=' + startKey + '&endkey=' + endKey;


this.start = new Date().getTime(); this.start = new Date().getTime();
Expand All @@ -93,8 +93,8 @@ CouchRepository.prototype.getEventsByName = function(type, from, callback) {


// Load function itself called once or multiple times. // Load function itself called once or multiple times.
var load = function(type, callback) { var load = function(type, callback) {
var startKey = '["' + type + '",' + from + ']', var startKey = '["' + type + '","' + from + '"]',
endKey = '["' + type + '",9999999999999]', endKey = '["' + type + '","9999999999999999"]',
params = '?startkey=' + startKey + '&endkey=' + endKey; params = '?startkey=' + startKey + '&endkey=' + endKey;


self.start = new Date().getTime(); self.start = new Date().getTime();
Expand Down
2 changes: 1 addition & 1 deletion lib/storage/couchStorage.js
Expand Up @@ -81,7 +81,7 @@ CouchStorage.prototype.loadView = function(id, callback) {
CouchStorage.prototype._loadBareView = function(id, callback) { CouchStorage.prototype._loadBareView = function(id, callback) {
this.request({ this.request({
method: 'GET', 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) { }, function(data) {
data = JSON.parse(data); data = JSON.parse(data);


Expand Down
5 changes: 5 additions & 0 deletions lib/util/couchdb.js
@@ -1,6 +1,11 @@
var http = require('http'), var http = require('http'),
nano = require('nano'); nano = require('nano');


/*
* Whole class would be replaced by nano!
* @depricated
*/

module.exports = CouchDb = function(options) { module.exports = CouchDb = function(options) {
options = options || {}; options = options || {};


Expand Down
8 changes: 4 additions & 4 deletions spec/repository/couchRepositorySpec.js
Expand Up @@ -76,7 +76,7 @@ describe('CouchRepository', function() {


expect(couchdb.request).toHaveBeenCalledWith({ expect(couchdb.request).toHaveBeenCalledWith({
method : 'GET', 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)); }, jasmine.any(Function));
}) })


Expand Down Expand Up @@ -105,7 +105,7 @@ describe('CouchRepository', function() {


expect(couchdb.request).toHaveBeenCalledWith({ expect(couchdb.request).toHaveBeenCalledWith({
method: 'GET', 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)); }, jasmine.any(Function));
}) })


Expand All @@ -115,12 +115,12 @@ describe('CouchRepository', function() {


expect(couchdb.request).toHaveBeenCalledWith({ expect(couchdb.request).toHaveBeenCalledWith({
method: 'GET', 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)); }, jasmine.any(Function));


expect(couchdb.request).toHaveBeenCalledWith({ expect(couchdb.request).toHaveBeenCalledWith({
method: 'GET', 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)); }, jasmine.any(Function));
}) })


Expand Down
2 changes: 1 addition & 1 deletion spec/storage/couchStorageSpec.js
Expand Up @@ -37,7 +37,7 @@ describe('CouchStorage', function() {
} }


function viewPath(id) { 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() { beforeEach(function() {
Expand Down

0 comments on commit 2ee4369

Please sign in to comment.