1
1
var DB = require ( 'sharedb' ) . DB ;
2
- var pg = require ( 'pg' )
2
+ var pg = require ( 'pg' ) ;
3
3
4
4
// Postgres-backed ShareDB database
5
5
@@ -29,7 +29,6 @@ function rollback(client, done) {
29
29
// Persists an op and snapshot if it is for the next version. Calls back with
30
30
// callback(err, succeeded)
31
31
PostgresDB . prototype . commit = function ( collection , id , op , snapshot , callback ) {
32
- console . log ( collection , id , op , snapshot )
33
32
/*
34
33
* op: CreateOp {
35
34
* src: '24545654654646',
@@ -60,10 +59,9 @@ PostgresDB.prototype.commit = function(collection, id, op, snapshot, callback) {
60
59
'SELECT max(version) AS max_version FROM ops WHERE collection = $1 AND doc_id = $2' ,
61
60
[ collection , id ] ,
62
61
function ( err , res ) {
63
- var max_version = res . rows [ 0 ] . max_version
62
+ var max_version = res . rows [ 0 ] . max_version ;
64
63
if ( max_version == null )
65
- max_version = 0
66
- console . log ( snapshot . v , max_version )
64
+ max_version = 0 ;
67
65
if ( snapshot . v !== max_version + 1 ) {
68
66
return callback ( null , false ) ;
69
67
}
@@ -149,7 +147,7 @@ PostgresDB.prototype.getSnapshot = function(collection, id, fields, callback) {
149
147
row . data ,
150
148
undefined // TODO: metadata
151
149
)
152
- callback ( null , snapshot )
150
+ callback ( null , snapshot ) ;
153
151
} else {
154
152
var snapshot = new PostgresSnapshot (
155
153
id ,
@@ -158,7 +156,7 @@ PostgresDB.prototype.getSnapshot = function(collection, id, fields, callback) {
158
156
undefined ,
159
157
undefined
160
158
)
161
- callback ( null , snapshot )
159
+ callback ( null , snapshot ) ;
162
160
}
163
161
}
164
162
)
@@ -181,7 +179,6 @@ PostgresDB.prototype.getOps = function(collection, id, from, to, callback) {
181
179
callback ( err ) ;
182
180
return ;
183
181
}
184
- console . log ( collection , id , from , to )
185
182
client . query (
186
183
'SELECT version, operation FROM ops WHERE collection = $1 AND doc_id = $2 AND version >= $3 AND version < $4' ,
187
184
[ collection , id , from , to ] ,
0 commit comments