Chapter 5: Indexing and Aggregation Pipeline Quiz: Upsert

After watching the lecture, I don’t understand why its not all the options given.

  • The upsert option is set to false by default
  • The upsert option is used with the update operator and needs to have its value specified every time that the update operator is called
  • When upsert is set to true and there is no result from the query then the update operation inserts a new document using the query and update predicates
  • When upsert is set to false and there is no result from the query then no updated documents occur

What is it that I am misunderstanding with upserts? Is it a definitional rationale between update operator versus update methods? Is it because the option narrows it to only update and not updateOne and updateMany?

I decided to waste me last chance to see the answer and the incorrect option was:

  • The upsert option is used with the update operator and needs to have its value specified every time that the update operator is called

I don’t think the lecture preceding this question articulated this point very well.

Hi @Ted_Holmberg,

Welcome to MongoDB Community Forum…!!!
And, Congratulations on Completing M001 - MongoDB Basic Course… :clap: :clap:

We apologize for your bad learning experience with the lecture of the course.
We will surely address your feedback regarding the course content and will try to improvise it.

Moreover, we highly encourage the learners to also go through the documentation link provided in the footnotes of the video lecture to get a deep and better understanding of the concept.

Here,

The upsert option only needs its value to be specified if we want to change the default value i.e., from false to true.

For better understanding
It would be represented something like this:

query upsert:true upsert:false
match update update
no match insert nothing

If you want you can read more about it here.

Let us know if you still have any questions.

:slightly_smiling_face:
Thanks,
Kushagra

I agree Ted - the upsert lecture is not very helpful at all.

1 Like

Hi @Aron_Deyo,

Welcome to MongoDB Community Forum.

Thanks for your feedback regarding lecture videos.
We apologize for the inconvenience caused to you while learning through our lectures.

We will surely consider your feedback regarding this and try to improve them.
Meanwhile, kindly refer to the docs here for a detailed explanation.

Regards,
Kushagra