I have problem when i try to insert Document in new collections

i am try to insert new document in my new collections Video.MovieScrach he has created two different moviesScrach please help me

It is because you made a typing error when you inserted the document.

Collections are created on the fly. So if you did db.MoviesScrach.insert( d ) rather than db.MoviesScratch.insert( d ) you inserted document d into the MoviesScrach collection. It is the normal behavior.

Hi @Abdirahman_yusuf_15183,

That’s a little strange. Where did you create these collections ? mongo shell or Compass ?

That being said, you can drop these collections by clicking on the delete icon in the Compass.

~ Shubham

i created this collections Mango compass

You created one with a trailing space "MoviesScrach ".

Connect to Mongo shell and run this command:
use video


HI @Abdirahman_yusuf_15183,

This :arrow_down:

You can drop collections by using the db.collection.drop() method.

~ Shubham

For a collection with a trailing space, you should use the db.getCollection( "name " ).drop() variant of drop().

See https://docs.mongodb.com/manual/reference/method/db.getCollection/ for more details.

1 Like

And for Compass

1 Like