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

How do you updating the metadata in a file-collection? #99

Closed ay13 closed 8 years ago

ay13 commented 8 years ago

I am wanting to change a field in the metadata section and i am having trouble.

i have tried a method call to the server and updating it like you would a normal collection but the value in metadata wont update.

i am trying to update metadata: {order: <num>}

myFiles is the FileCollection name

Meteor.methods({
    'imagesOrder' (md5, index) {
        myFiles.update({md5:md5}, {$set: {'metadata.order': index}})
    }
})
vsivsi commented 8 years ago

In this respect file-collections are just like any normal Meteor collection. The only "secret sauce" is logic to keep you from accidentally stomping on the gridFS managed attributes.

As I'm sure you can appreciate, debugging code with github issue comments is difficult and inefficient. If you can create a github project with a simple Meteor app that demonstrates the issue, I'll be happy to take a look.

ay13 commented 8 years ago

In writing a small example i was able to get it worked out. Easy to figure out once i broke it out of the large chunk of code i was working in.