如何将集合中的文本文件与fs集合中的图像相关联?

时间:2014-10-24 18:47:34

标签: node.js mongodb collections meteor

我正在开发流星的后端,现在我试图以某种方式将文本文件与图像相关联。有没有办法在fscollection中存储文本文件?如何将它们关联到两个不同的集合中?

这是我的两个系列:

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

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

在FsCollection中,我存储图像和其他集合存储数据,但它们都是同一记录的一部分。

1 个答案:

答案 0 :(得分:1)

您可以像在此一样使用FSCOllection中的元数据

在同一个FSCollection中你应该使用这个插入函数:

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);
}

});

在此之后,如果运行Images.find().fetch();

,则在FSCollection上插入一些元数据

您将在文档

中找到nameValueMetada:"cool stuff"