top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Can we modify the existing collection in mongoDB?

+2 votes
399 views

suppose, I have an existing capped collection with the following syntax.

db.createCollection("mycappedCollection",{capped: true, size: 2, max:2})

Now, what i want is to modify the above collection and add the autoIndexId option.
like:

db.createCollection("mycappedCollection",{capped: true, autoIndexId: true, size: 2, max:2})

How can I modify the existing mycappedCollection?

posted Jul 5, 2015 by Prakash Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

To change collection options, you need to create a new collection, copy all data from old one, then drop old one. This will spend a long time to complete when you have a large collection.

answer Feb 7, 2016 by Shivam Kumar Pandey
Similar Questions
+1 vote

I have a DB with several (quite big) collections, on Mongo 3.2.5 and WiredTiger with snappy compression on. I would like to change the compression setting on one small collection I have to test it uncompressed. Is there a possibility to do that on a secondary without having to resync the whole DB?

0 votes

I got the error when I was try to import the .csv file in collection, file size was about 4 gb. The error was: "An existing connection forcibly closed by remote host."

What is the probable reason and how can I increase the connection time in MongoDb?

...