Edward83
Edward83

Reputation: 6686

MongoDB GridFS bucket?

I work with MongoDB C# Samus driver.

One of constructors of class MongoDB.GridFS.GridFile has parameter "bucket". When i create GridFile in Java like example i cannot set this "bucket". But i can set this "bucket" in Java when create GridFS object Java documentation. I'm confused!

My question:

What is "bucket"? For what? Tell please some use cases;)

Upvotes: 4

Views: 5309

Answers (1)

pingw33n
pingw33n

Reputation: 12510

Bucket is base name for files and chunks collections. By default bucket is 'fs' so you will have two collections:

  • fs.files will store file properties like id, name, size, chunk size, md5 checksum etc.
  • fs.chunks will store the actual binary data split into chunks, one per document.

Using GridFS class constructor argument you can set arbitrary bucket name.

Different buckets can be useful if you need to have separate collections for different types of files, so you can apply different indexes, sharding etc.

Upvotes: 13

Related Questions