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

做~自己de王妃 提交于 2020-01-15 12:07:07

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/26554346/how-to-associate-a-text-file-in-a-collection-with-an-image-in-a-fs-collection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!