-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace deprecated mongodb $pushAll operator with $push + $each #4455
Comments
Getting off of pushAll is definitely a priority, but fair warning, mongoose does not support documentdb at the moment, so use it at your own risk |
This may mitigate the impact of Array.push relying on $pushAll. I tried it myself and seems to work. myArray.push(myObject); //breaks on DocumentDB with Mongo API because of $pushAll instead use myArray = myArray.concat([myObject]); //this uses $set so no problems @vkarpov15 Supporting DocumentDB with Mongo Protocol (so not DocumentDB as it is) would be fantastic, even though I can understand that project priorities are on Mongo. Sadly Microsoft seem to have implemented just a fair subset of the latest Mongo API (3.x), so deprecated stuff that comes from 2.x may not work. |
In 4.6.4 you'll be able to use the |
Started running into this problem on Mongo 3.6 and Mongoose 4.13.6, Suggested fix does not work:
It's weird that this is still an issue with the updated libs? |
Same as Knutole here, I'm creating models with mongoose and I don't know if / where I can plugin that fix. |
Edit 1: Edit 2: |
Same issue here using Mongo 3.6 |
Workaround |
@knutole what issue are you running into? This solution has worked for me. @frguthmann safest bet would be to add that line to all models if you're using MongoDB 3.6+. |
Mongo 3.6 was recently released and removed support for $pushAll, so everyone downloading the latest and greatest mongo will run into this. The solution here is to either
OR
I recommend #1 for production apps. |
@knutole That solution worked fine for me. Using v3.6
Gives no errors. |
There's a fix for this in the upcoming 5.0.0-rc0 release, for now just use the usePushEach option. |
Fix works in the 5.0.0-rc2 release. |
According to MongoDB documentation
$pushAll
has been deprecated since version 2.4. However, it remains the operator Array#push translates into.On the assumption that is not a breaking change, I think it would be a convenient fix, since some implementation may not rely on
$pushAll
. In fact, for what it is worth, Azure's own MongoDB implementation does not support$pushAll
operator AFAIK .The text was updated successfully, but these errors were encountered: