toofarsideways
toofarsideways

Reputation: 3972

Is there a version limit in GridFS?

In mongodb GridFS when you insert a file with the same name as an already existing file the old file becomes a previous version of the new file.

I'm wondering can I do this multiple times and is there a limit?

For example, I have a file file.txt, then I insert another file.txt, now I have two versions of file.txt. I now insert a third file.txt. Do I now have three versions of the file? Or just two? How many more times can I insert file.txt and keep all the previous versions?

Finally, how do I access these previous versions or overwrite them?

Upvotes: 0

Views: 402

Answers (1)

Kay
Kay

Reputation: 3012

There is no built-in limit on the number of versions, but it may be that a particular driver may set some limit.

As for getting a specific version, are you by any chance using a specific driver? For instance, I believe pyMongo has a get_version() api which allows you to specify a particular version of the file.

As for replacing files, if you're running mongofiles utility in the shell, you can specify -r to replace a document -- such as mongofiles -r put file.txt -- which would leave you with just this version of file.txt. There may be different implementation with specific drivers.

Regards,

Kay

Upvotes: 2

Related Questions