user3968749
user3968749

Reputation:

How to associate a text file in a collection with an image in a fs collection?

I'm developing a back end in meteor, now I'm trying to associate a text file with images, in some way. Is there a way to storage text files in a fscollection? How can I associate them in two different collections?

These are my two collections:

Images = new FS.Collection("Images", {
  stores: [new FS.Store.FileSystem("Images", {path: "~/padonde/uploads"})]
});

Reynosa = new Mongo.Collection("Reynosa");

In the FsCollection, I storage images and in the other collection storage data, but both of them would be a part of the same record.

Upvotes: 1

Views: 230

Answers (1)

Ethaan
Ethaan

Reputation: 11376

You Can use Metadata inside the FSCOllection like this

In the same FSCollection you should use this insert function:

Template.templateName.events({
'click #clickEvent' : function(){

var file = $('#addImagenPromocion').get(0).files[0]; // Stores temporaly the FSFile
var fsFile = new FS.File(file); // take the FS.File object
fsFile.metadata = {nameValueMetadata:"Cool Stuff"};
Images.insert(fsFile);
}

});

So after this you insert Some metadata on the FSCollection, if you run Images.find().fetch();

and you will se the nameValueMetada:"cool stuff" value inside document

Upvotes: 1

Related Questions