Summery of "The $out stage" confusing: "if specified"

In de summary of “The $out stage” the first bullet says "Will create a new collection of overwrite an existing collection if specified.

The documentation says an existing collection is always overwritten, so what do you mean with “if specified”?

What I understand when I read this sentence is that it is possible to choose to overwrite an existing collection or not, by providing an additional document like {allowDiskUse: true}.


No. If you specify an $out collection that matches an existing collection, the existing collection will be overwritten., On the other hand, if you specify an $out collection that does not yet exist, it will be created. So an existing collection is overwritten if the collection specified already exists.

Hi. Thanks, but that part is already couvert: “Will create a new collection or overwrite an existing collection”. Maybe it is my onderstanding of the language, but for me it is confusing.

As I said before. There could be three possibilities:

  1. the collection is created when non existant
  2. the documents are appended is the collection exists
  3. the collection is replaced “if specified”, for example with {“append”:false"} or something like that

When I see the sentence “if specified” I ask myself “what if not specified”. And how do I do that?


I think this is a language problem, but in any case you should always take the official MongoDB documentation as the canonical source.