Skip to main content
Refering to alternative answer since this one is apparently outdated.
Source Link
Niels van der Rest
  • 32.3k
  • 16
  • 82
  • 87

Apparently there is a way to do this efficiently since MongoDB 3.4, see styvane's answer.


Obsolete answer below

You cannot refer to the document itself in an update (yet). You'll need to iterate through the documents and update each document using a function. See this answer for an example, or this one for server-side eval().

You cannot refer to the document itself in an update (yet). You'll need to iterate through the documents and update each document using a function. See this answer for an example, or this one for server-side eval().

Apparently there is a way to do this efficiently since MongoDB 3.4, see styvane's answer.


Obsolete answer below

You cannot refer to the document itself in an update (yet). You'll need to iterate through the documents and update each document using a function. See this answer for an example, or this one for server-side eval().

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

You cannot refer to the document itself in an update (yet). You'll need to iterate through the documents and update each document using a function. See this answerthis answer for an example, or this onethis one for server-side eval().

You cannot refer to the document itself in an update (yet). You'll need to iterate through the documents and update each document using a function. See this answer for an example, or this one for server-side eval().

You cannot refer to the document itself in an update (yet). You'll need to iterate through the documents and update each document using a function. See this answer for an example, or this one for server-side eval().

Add link to eval example
Source Link
Dan Dascalescu
  • 153.6k
  • 66
  • 336
  • 422

You cannot refer to the document itself in an update (yet). You'll need to iterate through the documents and update each document using a function. See this answer for an example, or this one for server-side eval().

You cannot refer to the document itself in an update (yet). You'll need to iterate through the documents and update each document using a function. See this answer for an example.

You cannot refer to the document itself in an update (yet). You'll need to iterate through the documents and update each document using a function. See this answer for an example, or this one for server-side eval().

Source Link
Niels van der Rest
  • 32.3k
  • 16
  • 82
  • 87
Loading