If a document is deleted in Rethink while there's a changefeed watching, it will return:
{
new_val: null,
old_val: { someData... }
}
This isn't particularly useful to our transform function because it would only receive null. This PR updates saveDocument and watchTable so user-specified transform functions now receive document and oldDocument.
This PR also adds the ability to specify a deleteTransform, which runs specifically when new_val is null, meaning a delete took place in Rethink. This is a breaking change. When a deleteTransform is not specified, this library will default to just deleting the document from Elasticsearch, using the id (with respect to the id field) from oldDocument. Previously, the document would've just been passed to transform as null.
If a document is deleted in Rethink while there's a changefeed watching, it will return:
This isn't particularly useful to our
transform
function because it would only receive null. This PR updatessaveDocument
andwatchTable
so user-specifiedtransform
functions now receivedocument
andoldDocument
.This PR also adds the ability to specify a
deleteTransform
, which runs specifically whennew_val
is null, meaning a delete took place in Rethink. This is a breaking change. When adeleteTransform
is not specified, this library will default to just deleting the document from Elasticsearch, using the id (with respect to the id field) fromoldDocument
. Previously, the document would've just been passed totransform
as null.