- Wrap retry in try/catch and emit
processError
on exception.
- Added
renameKeys
utility function used in downstream libraries. - Bumped packages.
- Add retry logic to
processRecords
. Downstream libraries should only throw if the error is transient and can be retried with eventual success. - Changed to ES module.
- Bug Fix:
processRecords
could mutate so we need to derive values for state tracking prior to calling the function.
- Bump packages, including latest
prom-utils
which addslastFlush
tobatchQueue
. - Added
lastFlush
tostats
event.
- Add
documentKey
to pseudoChangeStreamInsertDocument
event for initial scan.
- Use
$match
to filteroperationType
.
- Added
pausable
topause
andresume
all syncing operations. - Removed deprecated
shouldRemoveMetadata
option.
- Bump packages, including latest
prom-utils
which allows for throttling of items/sec and bytes/sec. - New event:
stats
which emits stats for items/sec and bytes/sec when a batch of records is processed for the initial scan or change stream.
- Don't assume that
updateDescription
will be on the change stream event.
- Fixed bug where
processChangeStream
exits prematurely. - Fixed bug when omitting an updated nested field.
- Omit fields from
updateDescription.removedFields
to prevent downstream issues.
- Bumped peer dependencies for
mongodb
. - Reworked
safelyCheckNext
.
- Bumped peer dependencies for
ioredis
andmongodb
.
- Added
uniqueId
option to allow the same collection to be synced in parallel. - Deprecated option
shouldRemoveMetadata
indetectSchemaChange
. PrefershouldRemoveUnusedFields
.
- Bump dependencies.
- Escape period in regex.
- Fix issue where omitting nested paths failed to remove the field from
updateDescription.updatedFields
do to dotted field name.
- Optionally pass an array of operation types (
insert
,update
, ...) toprocessChangeStream
. This allows you to skip operations you don't care about. For example, adelete
operation due to a collection TTL index.
- NOTE: Breaking change!
processChangeStream
is now batched, meaning the callback now receives an array of change stream events.
- More robust error code handling for
missingOplogEntry
.
- Don't emit the
cursorError
event when stopping.
- Expose FSM via
state
property forrunInitialScan
andprocessChangeStream
.
- Fix bug with fsm. Added accompanying test.
- Remove all health check code in favor of using the
cursorError
event. - Simplify some code.
- Add support for sort order (asc, desc) on initial scan.
- Emit
cursorError
when an error occurs when callinghasNext
. Useful for debugging syncing issues like a missing oplog entry caused by an inadequate oplog window. missingOplogEntry
utility function.- Change stream health check behavior has changed. The
healthCheck.field
option has been removed since determining a failed health check relies on a delayed check of a Redis key and not a MongoDB query. - Type parameter on
initSync
to allow for extending the event emitter. Useful for downstream libraries likemongo2mongo
andmongo2elastic
.
- Optional
pipeline
forrunInitialScan
.
- Handle master failover scenario properly for initial scan.
- Emit
initialScanComplete
when initial scan is complete.
- Bump default
maxSyncDelay
to 5 minutes.
- Fixed cursor exhausted bug with initial scan.
- Simplified change stream cursor consumption.
- Resync flag via
detectResync
. - Changed health check options for both initial scan and change stream.
- Change stream health checker requires a date field to determine if syncing has stopped.
- Better handling of state transitions.
- Explicit types for health check failure.
- Emit the following field to differentiate failure types:
failureType
with valuesinitialScan
andchangeStream
.
- Fixed bug preventing a previously completed initial scan from being stopped once restarted.
- Renamed
maintainHealth
toenableHealthCheck
. - Health check only emits now. You must call
restart
manually to reproduce the previous behavior.
- Make schema change event more specific -
change
is nowschemaChange
.
- Don't type event emitter so that it can be reused by downstream libraries like
mongo2crate
andmongo2elastic
.
- BREAKING CHANGE: Moved emitter to top level.
- Emit event
healthCheckFail
if a health check fails.
Document
type should refer to type frommongodb
not DOM.
- BREAKING CHANGE:
processChangeStream
now takes an option object instead of a pipeline for the second argument. - Added
restart
fn torunInitialScan
andprocessChangeStream
. - Added the following options to
runInitialScan
andprocessChangeStream
:maintainHealth
andhealthCheckInterval
. WhenmaintainHealth
is set totrue
a failure to write a record when performing an initial scan withinhealthCheckInterval
will causerunInitialScan
to restart. WhenmaintainHealth
is set totrue
a failure to process the latest insert withinhealthCheckInterval
when processing a change stream will causeprocessChangeStream
to restart. - Use more generic
Record<string, any>
for typeJSONSchema
.
- Latest
prom-utils
that includesbatchBytes
option.
- Use
eventemitter3
.
JSONSchema
type.
- Option to strip metadata from a JSON schema for
detectSchemaChange
. - You can now await
changeStream.start
which resolves after the initial change detection has completed.
- Ensure that you can call
start
after callingstop
.
- Bump
mongodb
peer dep.
- Fix issue with
runInitialScan
where callingstop
before the scan had finished would incorrectly set the scan completed key in Redis. Also,stop
now awaits flushing the queue.
- BREAKING CHANGE: Changed API for
runInitialScan
. You must explicitly callstart
now. The change stream can be stopped by callingstop
. - It is now possible to cleanly stop
runInitialScan
andprocessChangeStream
, allowing for a smooth restarting behavior if a schema change is detected.
- Await processing of event when calling
stop
.
- BREAKING CHANGE:
initSync
now takescollection
. - NEW:
detectSchemaChange
.
- BREAKING CHANGE: Changed API for
processChangeStream
. You must explicitly callstart
now. The change stream can be stopped by callingstop
.
- Export
getCollectionKey
util.
- Bump peer dependencies.
- Omit nested fields for
update
operations.
- Fix
Document
type.
- Prepend
pipeline
with omit pipeline ifomit
is passed toinitSync
.
- Renamed
Options
toSyncOptions
.
- Moved
omit
toinitSync
so that it can be used in theprocessChangeStream
pipeline.
- Don't delete the last scan id key when initial scan is completed.
- Allow an initial scan to resume after completion by calling
clearCompletedOn
first. - Export
getKeys
fn. - Changed Redis key prefix from to
mongoChangeStream
.
omit
option for excluding undesired fields.
sortField
option for overriding the default sorting field of_id
.
- Pass
QueueOptions
torunInitialScan
.
- Bumped
prom-utils
to latest.
- Batch
runInitialScan
.
- Separate out event stream handling into the
processChangeStream
method.
- Initial release.