codepunkt / mongoose-patch-history

Mongoose plugin that saves a history of JSON patch operations for all documents belonging to a schema in an associated 'patches' collection
MIT License
96 stars 21 forks source link

Breaking change in new released version v1.4.0: MongoError: unknown top level operator: $push #65

Closed BMartinos closed 4 years ago

BMartinos commented 4 years ago

Hi Team

Thanks for the new release of this module.

I have however picked an issue which has caused a breaking change to occur. It seems that the $push operation is no longer supported with the new changes introduced. Within your test script you have a test which should verify this but it doesnt seem to be working in a real world scenario.

I have created a basic gist of the files and steps needed to reproduce the error. I have made use of your actual test file in the master branch and removed the unrelated sections for this issue (Only testing the $push related operation). https://gist.github.com/BMartinos/d24dab6cb6d5b77600a5aeb990c0d40f

The error being returned when executing the reproducible test script can be seen below:

Error:  { MongoError: unknown top level operator: $push
    at MessageStream.messageHandler (/../mongoose-patch-history-test/node_modules/mongodb/lib/cmap/connection.js:266:20)
    at MessageStream.emit (events.js:198:13)
    at processIncomingData (/../mongoose-patch-history-test/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
    at MessageStream._write (/../mongoose-patch-history-test/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
    at doWrite (_stream_writable.js:415:12)
    at writeOrBuffer (_stream_writable.js:399:5)
    at MessageStream.Writable.write (_stream_writable.js:299:11)
    at Socket.ondata (_stream_readable.js:710:20)
    at Socket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17) ok: 0, code: 2, codeName: 'BadValue', name: 'MongoError' }
codepunkt commented 4 years ago

Hey @BMartinos, thanks for the report!

Would you mind trying to install from master via npm i codepunkt/mongoose-patch-history or yarn add codepunkt/mongoose-patch-history and telling us whether this is fixed there or not?

BMartinos commented 4 years ago

@codepunkt great thanks! Pulling from your master branch resolved my issue. Any idea of when this might be published to npm?

vinerich commented 4 years ago

@BMartinos I'd say as soon as I figured #63 out to work as I want it too ๐Ÿ˜… I'm actively working on getting it resolved so hopefully this week.

BMartinos commented 4 years ago

Ok great thanks for the quick feedback @vinerich Will keep an eye out for when the new version is released. Thanks

vinerich commented 4 years ago

@BMartinos done ๐Ÿ‘Œ๐Ÿพ 2.0.0 was released by @codepunkt and includes the fixes for $pull, $push + new excludes and rollback without save option!

BMartinos commented 4 years ago

@vinerich @codepunkt Awesome! thanks for the new release and quick response :). I can confirm this fix is now also in the newly released npm update and working again for me.