question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Replace deprecated mongodb $pushAll operator with $push + $each

See original GitHub issue

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 .

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13

github_iconTop GitHub Comments

14reactions
lamuertepeludacommented, Sep 29, 2016

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.

9reactions
vkarpov15commented, Oct 8, 2016

In 4.6.4 you’ll be able to use the usePushEach option in schemas: new Schema({ arr: [String] }, { usePushEach: true });

Read more comments on GitHub >

github_iconTop Results From Across the Web

$pushAll — MongoDB Manual
Deprecated since version 2.4: Use the $push operator with $each instead. The $pushAll operator appends the specified values to an array.
Read more >
Replace deprecated mongodb $pushAll operator with $push + $each
According to MongoDB documentation $pushAll has been deprecated since version 2.4. However, it remains the operator Array#push translates into.
Read more >
why $pushAll deprecated but $pullAll not? - mongodb
mongodb document said that $pushAll is Deprecated since version 2.4: Use the $push operator with $each instead. so I changed all occur of...
Read more >
MongoDB/Mongoose Challenge #8 [SOLVED] - JavaScript
According to MongoDB documentation $pushAll has been deprecated since version 2.4. However, it remains the operator Array#push translates into.
Read more >
Deprecated List (Spring Data MongoDB 3.3.0-RC1 API)
since 2.2. The eval command has been removed without replacement in MongoDB Server 4.2.0. Deprecated Classes. Class and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found