Skip to content

Commit 51f1c57

Browse files
committed
by doc, getOps return ops to the latest version if version is null. additionally, ops have to be sorted for things like fetchSnapshots to work.
1 parent cd5b2ef commit 51f1c57

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,12 @@ PostgresDB.prototype.getOps = function(collection, id, from, to, options, callba
137137
callback(err);
138138
return;
139139
}
140-
client.query(
141-
'SELECT version, operation FROM ops WHERE collection = $1 AND doc_id = $2 AND version > $3 AND version <= $4',
142-
[collection, id, from, to],
140+
141+
var cmd = 'SELECT version, operation FROM ops WHERE collection = $1 AND doc_id = $2 AND version > $3 ';
142+
var params = [collection, id, from];
143+
if(to || to == 0) { cmd += ' AND version <= $4'; params.push(to)}
144+
cmd += ' order by version';
145+
client.query( cmd, params,
143146
function(err, res) {
144147
done();
145148
if (err) {

0 commit comments

Comments
 (0)