Changes
- #236 - Add milestone snapshots, which are persisted snapshots of documents at previous versions, used to speed up
Backend#fetchSnapshot
. (@alecgibson)
About MilestoneDB
This adds a new MilestoneDB class, which handles persisting milestone snapshots, with a default no-op base implementation. Methods:
MilestoneDB.getMilestoneSnapshot(collection, id, version, callback): void
MilestoneDB.saveMilestoneSnapshot(collection, snapshot, callback): void
To persist milestone snapshots:
- Pass in a real implementation of MilestoneDB (to come later) when constructing Backend:
new Backend({milestoneDb})
- When constructing a real MilestoneDB, decide whether to save milestone snapshots by default for all collections:
- Pass in the
interval
option to save milestone snapshots everyinterval
versions by default. - Or don't pass the
interval
option to turn off saving of milestone snapshots by default.
- Pass in the
- For fine-grained control over when to save a milestone snapshot, register middleware on the
'commit'
action and set therequest.saveMilestoneSnapshot
property totrue
orfalse
to explicitly enable or disable milestone snapshot saving on that commit. If the property is left at its default value ofnull
, then the defaultinterval
is used, if that was specified when constructing the MilestoneDB.