Updating Documents: replaceOne() Command errors

This error refers to the following code:

let filter = {title: "House, M.D., Season Four: New Beginnings"}
let doc = db.movieDetails.findOne(filter);
doc

I am able to type in the first two lines correctly. However when I type in “doc”, a “null” is returned:40%20PM

I do not understand what I am doing wrong. I am simply copying and pasting the commands from the m001/replaceOne.js file. Any help would be greatly appreciated.

Please check you are connected to the correct cluster(Class vs Sandbox)
I think you are connected to Class cluster
Please check if you can see the collection on which you are running the query
by

show collections

Hi @Shawn_97484,

Your query is returning null because you are issuing query on a collection (video.movieDetails) which does not exist in the Atlas class cluster.

In order to be able to run this query, please connect to your Sandbox cluster.

The Class Atlas Cluster is owned by MongoDB and all the users have only Read Access to the databases in this cluster. You cannot perform Create, Update and Delete operation on the documents present in this cluster. This is so because we do not want any user to modify the contents of the databases and also to ensure every user has a consistent view of the data.

The Sandbox Atlas Cluster is created by each individual user such as you and you are the owner of this cluster with all the ReadandWrite access. In this cluster you load the video database and perform all sorts of CRUD operations.

If you still have any query, feel free to get back to us. Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

What command would I run to connect to the cluster?

There is no fixed connect string for Sandbox cluster(your own) like we have for Class cluster
Each student has his own connect string
Please go thru the chapter creating Sandbox cluster.From there you can get your connect string

Hi @Shawn_97484,

If you have already created the sandbox cluster then please follow the steps mentioned in this post to get the connection string of your sandbox cluster.

If you have not created any atlas cluster yet then please refer the Lecture: Lab 2.0: Create an Atlas Sandbox Cluster (Ungraded).

Hope it helps!

If you have any other issue, please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer