Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit 11d982d

Browse files
author
Alec Gibson
committed
Rename Snapshot middleware "historical" flag to "byVersion"
Calling a snapshot "historical" might lead people to assume that it's not the current version, which may not be the case (for example, if you fetch the current version by its ID with `fetchSnapshot` or, pass in a version of `null`). This change updates the snapshot middleware to use the more descriptive `byVersion`, which indicates that the snapshot was fetched by version.
1 parent 41f2395 commit 11d982d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/backend.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ Backend.prototype.MIDDLEWARE_ACTIONS = {
8080
Backend.prototype.SNAPSHOT_TYPES = {
8181
// The current snapshot is being fetched (eg through backend.fetch)
8282
current: 'current',
83-
// An historical snapshot is being fetched (eg through backend.fetchSnapshot)
84-
historical: 'historical'
83+
// A specific snapshot is being fetched by version (eg through backend.fetchSnapshot)
84+
byVersion: 'byVersion'
8585
};
8686

8787
Backend.prototype._shimDocAction = function() {
@@ -615,7 +615,7 @@ Backend.prototype.fetchSnapshot = function(agent, index, id, version, callback)
615615
if (error) return callback(error);
616616
var snapshotProjection = backend._getSnapshotProjection(backend.db, projection);
617617
var snapshots = [snapshot];
618-
var snapshotType = backend.SNAPSHOT_TYPES.historical;
618+
var snapshotType = backend.SNAPSHOT_TYPES.byVersion;
619619
backend._sanitizeSnapshots(agent, snapshotProjection, collection, snapshots, snapshotType, function (error) {
620620
if (error) return callback(error);
621621
backend.emit('timing', 'fetchSnapshot', Date.now() - start, request);

test/client/snapshot-request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ describe('SnapshotRequest', function () {
228228
backend.use(backend.MIDDLEWARE_ACTIONS.readSnapshots,
229229
function (request) {
230230
expect(request.snapshots[0]).to.eql(v3);
231-
expect(request.snapshotType).to.be(backend.SNAPSHOT_TYPES.historical);
231+
expect(request.snapshotType).to.be(backend.SNAPSHOT_TYPES.byVersion);
232232
done();
233233
}
234234
);

0 commit comments

Comments
 (0)