vsivsi / meteor-file-collection

Extends Meteor Collections to handle file data using MongoDB gridFS.
http://atmospherejs.com/vsivsi/file-collection
Other
159 stars 37 forks source link

allow replace mongo url on grid #169

Open crapthings opened 6 years ago

crapthings commented 6 years ago

meteor has remoteCollectionDriver method to change mongourl

but call remoteCollectionDriver method doesnt

have to replace grid db driver too

crapthings commented 6 years ago
     @gfs = new grid(@db, mongodb, @root)

grid server coffe

change this and collection._driver maybe

vsivsi commented 6 years ago

Hi, I'm not really understanding exactly what you are proposing or what problem it will solve. Can you please explain in a bit more detail what this is about?

crapthings commented 6 years ago

oh sorry about my english, i was on my phone, let me try to explain.

a meteor collection can change mongourl by using MongoInternals.RemoteCollectionDriver

_driver = new MongoInternals.RemoteCollectionDriver(MONGO_URL)
Docs = new Mongo.Collection('docs', { _driver })

and we can even change mongourl dynamically by reassign collection._driver

Docs._driver = new MongoInternals.RemoteCollectionDriver(NEW_MONGO_URL)

but with file collection, changing collection._driver seems not working.

maybe we can add a method to reassign @gfs = new grid(@db, mongodb, @root)

https://github.com/vsivsi/meteor-file-collection/blob/master/src/gridFS_server.coffee#L48

i think we can

const Docs = new FileCollection('docs')
const _driver = new MongoInternals.RemoteCollectionDriver(MONGO_URL)

a method that change both mongourl

Docs._driver = _driver
const gfs = new Grid(_driver.mongo.db, ...)

https://github.com/meteor/meteor/blob/devel/packages/mongo/remote_collection_driver.js