【发布时间】:2016-12-02 20:29:09
【问题描述】:
我创建了一个名为 Stampest 的集合,其中存储了用户创建的上传图像和标题字符串的引用。使用ostrio:autoform package.This 包创建一个名为Images 的集合,其中存储所有用户上传的图像并因此引用/引用。
当我在终端中使用
查询 mongodb.stampest.find({})
我得到了条目
这表明数据库中有文档,在Stampest 集合中。但是问题是当我在Meteor Toys调试中查看集合时,它说它是空的,当我插入一个文档时,在这种情况下,图像和标题,集合变为1 瞬间,geos 回到 0。终端或控制台没有错误
因此,我无法访问这些文档,我该怎么办?
这是 schema.js
Schemas = {};
Stampest = new Meteor.Collection('stampest');
Stampest.allow({
insert: function (userId, doc) {
return userId;
},
update: function (userId, doc, fields, modifier) {
// can only change your own documents
return doc.userId === userId;
},
remove: function (userId, doc) {
// can only remove your own documents
return doc.userId === userId;
}
});
Schemas.Stampest = new SimpleSchema({
title: {
type: String,
max: 60
},
picture: {
type: String,
autoform: {
afFieldInput: {
type: 'fileUpload',
collection: 'Images',
// uploadTemplate: 'uploadField' // <- Optional
// previewTemplate: 'uploadPreview' // <- Optional
}
}
}
});
Stampest.attachSchema(Schemas.Stampest);
publish是这样的:
Meteor.publish('stampest', function () {
return Stampest.find({author: this.userId}).fetch();
console.log(Stampest.find());
});
用户像这样插入image 和title:
<template name="createStamp">
<div class="grid-block">
<div class="grid-container">
<div class="upload-img">
<a href="{{file.link}}">{{file.original.name}}</a>
</div>
<div class="new-stamp-container">
{{> quickForm collection="Stampest" type="insert" id="insertStampForm" class="new-stamp-form"}}
</div>
</div>
</div>
</template>
【问题讨论】:
-
使用meteor mongo检查服务器。如果记录在那里,那将是您订阅数据的方式有问题
标签: mongodb meteor file-upload meteor-packages