unify streams
This commit is contained in:
parent
f4651cadae
commit
3ede1ea9f1
@ -12,8 +12,7 @@ module.exports = class StreamCopy {
|
|||||||
this.sql = sql;
|
this.sql = sql;
|
||||||
this.connectionClosedByClient = false;
|
this.connectionClosedByClient = false;
|
||||||
|
|
||||||
this.copyToStream = null;
|
this.stream = null;
|
||||||
this.copyFromStream = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static get ACTION_TO() {
|
static get ACTION_TO() {
|
||||||
@ -30,8 +29,8 @@ module.exports = class StreamCopy {
|
|||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.copyToStream = copyTo(this.sql);
|
this.stream = copyTo(this.sql);
|
||||||
const pgstream = client.query(this.copyToStream);
|
const pgstream = client.query(this.stream);
|
||||||
|
|
||||||
pgstream
|
pgstream
|
||||||
.on('end', () => done())
|
.on('end', () => done())
|
||||||
@ -55,8 +54,8 @@ module.exports = class StreamCopy {
|
|||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.copyFromStream = copyFrom(this.sql);
|
this.stream = copyFrom(this.sql);
|
||||||
const pgstream = client.query(this.copyFromStream);
|
const pgstream = client.query(this.stream);
|
||||||
|
|
||||||
pgstream
|
pgstream
|
||||||
.on('end', () => done())
|
.on('end', () => done())
|
||||||
@ -69,13 +68,7 @@ module.exports = class StreamCopy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getRowCount(action = ACTION_TO) {
|
getRowCount() {
|
||||||
if (action === ACTION_TO && this.copyToStream) {
|
return this.stream.rowCount;
|
||||||
return this.copyToStream.rowCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action === ACTION_FROM && this.copyFromStream) {
|
|
||||||
return this.copyFromStream.rowCount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user