I have two different meteor collections, one a file collection to store images:
我有两个不同的流星集合,一个是用于存储图像的文件集合:
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: "~/uploads"})]
});
and the other a collection to store information about these images:
另一个用于存储有关这些图像的信息的集合:
Photos = new Mongo.Collection("photos");
Photos.attachSchema(new SimpleSchema({
userId:{
type: String,
autoValue:function(){return this.userId},
},
userName:{
type: String,
autoValue:function(){return Meteor.users.findOne({_id: this.userId}).username},
},
groupMembers: {
type: String
},
comments: {
type: String,
autoform:{
rows: 5
}
},
fileId: {
type: String
}
}));
I built this helper function to help display the data on a template:
我构建了这个帮助函数来帮助显示模板上的数据:
Template.imagesSubmitted.helpers({
photos: Photos.find(),
image: function(){Images.findOne({_id: Template.instance().data.image}).url();
}
});
Images.allow({
download: function () {
return true;
},
fetch: null
});
And here is the HTML code to display the images and information about the photos:
以下是用于显示照片的图像和信息的HTML代码:
</template>
<template name = "imagesSubmitted">
List of photos
{{#each photos}}
<div class = "uploadedImage">
This is an image
{{> photo}}
<img src="{{this.image}}" class = "tableImage" alt="thumbnail">
</div>
{{/each}}
</template>
Unfortunately, the page doesn't display anything from either database. The images only display as the alternate "thumbnail" and {{>photo}}
doesn't seem to display any information from the Photos collection.
不幸的是,该页面不显示任何数据库中的任何内容。图像仅显示为备用“缩略图”,而{{> photo}}似乎不显示“照片”集合中的任何信息。
Is there a way to fix this? Also is there a way to streamline this so that I'm only using one collection and still able to use cfs:autoform to create and publish the form that collects images?
有没有办法来解决这个问题?还有一种简化方法,以便我只使用一个集合,仍然能够使用cfs:autoform来创建和发布收集图像的表单?
2 个解决方案
#1
Did you tried by using that query in your browser console? Like Photos.find().fetch(); And are you defining photo template?
您是否尝试在浏览器控制台中使用该查询?像Photos.find()。fetch();你定义照片模板了吗?
#2
Be sure to allow download function.
From the docs:
一定要允许下载功能。来自文档:
Images.allow({
download: function(userId, fileObj) {
return true
}
})
#1
Did you tried by using that query in your browser console? Like Photos.find().fetch(); And are you defining photo template?
您是否尝试在浏览器控制台中使用该查询?像Photos.find()。fetch();你定义照片模板了吗?
#2
Be sure to allow download function.
From the docs:
一定要允许下载功能。来自文档:
Images.allow({
download: function(userId, fileObj) {
return true
}
})