meteor-file-collection icon indicating copy to clipboard operation
meteor-file-collection copied to clipboard

allow replace mongo url on grid

Open crapthings opened this issue 7 years ago • 3 comments

meteor has remoteCollectionDriver method to change mongourl

but call remoteCollectionDriver method doesnt

have to replace grid db driver too

crapthings avatar Oct 23 '17 10:10 crapthings

     @gfs = new grid(@db, mongodb, @root)

grid server coffe

change this and collection._driver maybe

crapthings avatar Oct 23 '17 10:10 crapthings

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?

vsivsi avatar Oct 23 '17 19:10 vsivsi

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

crapthings avatar Oct 24 '17 01:10 crapthings