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

Possibility to set a custom _id #147

Closed javascriptlove closed 6 years ago

javascriptlove commented 7 years ago

Hi, this is rather a question than an issue. But it would solve some troubles on my end, what i'm interested in is this line https://github.com/vsivsi/meteor-file-collection/blob/master/src/gridFS_server.coffee#L99

Can we have a Match.Where here and check if _id is already a valid Mongo.ObjectId and only create a new id if it isn't? Something like in this pull?

(Please correct the code if there's a need, i'm not used to coffeescript)

vsivsi commented 7 years ago

Hi, I'm pretty sure that's how it already works.

The implementations of fc.insert() on both client and server call a function share.insert_func() that contains code to handle the case you describe:

https://github.com/vsivsi/meteor-file-collection/blob/master/src/gridFS.coffee#L13-L16

If you are having problems getting that to work as expected, please point me to some code that reproduces the issue and I'll look into it.

vsivsi commented 6 years ago

Closing, no further action required.