aheckmann / gridfs-stream

Easily stream files to and from MongoDB
MIT License
615 stars 120 forks source link

Fixed error when using different collection name #8

Closed DominicBoettger closed 10 years ago

DominicBoettger commented 11 years ago

Signed-off-by: DominicBoettger Dominic.Boettger@inspirationlabs.com

When creating a readstream with a different collection name it's needed to add the root. "files" and "chunks" then gets automatically added.

Tested for Readstream!

aheckmann commented 11 years ago

Can you explain a little more? Is it broken now? I'd feel more comfortable accepting this pull request if you add a test.

DominicBoettger commented 11 years ago

It was not possible to create a Readstream with your settings cause "MYNAME.files" is not the valid collection.

Grid.prototype.collection = function (name) { name || (name = this.mongo.GridStore.DEFAULT_ROOT_COLLECTION); return this._col = this.db.collection(name); }

this.mongo.GridStore.DEFAULT_ROOT_COLLECTION returns "fs" and not fs.files

So if you set the collection you must not append + ".files".

I thought there was already a test for collection, did not check that..... If there is already a test it should always fail on creating a readstream with a collection which is not the defaultcollection.

aheckmann commented 10 years ago

no test after 10 months. closing.