我想更新我的应用程序,以利用Meteors建议的文件结构,我无法将发布功能与架构文件分开。我想使用的文件结构单独发布功能我们的架构和进入服务器/ publications.js
imports/
api/
profile/
server/
publications.js
Profile.js
当我结合发布功能到Profile.js模式文件发布功能的作品,当我把它们分开,我的数据流经然而到客户端无法将其发布。有人可以告诉我如何正确分离发布功能和模式。
路径:imports/api/profile/Profile.js
import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { AddressSchema } from '../../api/profile/AddressSchema.js';
import { ContactNumberSchema } from '../../api/profile/ContactNumberSchema.js';
export const Profile = new Mongo.Collection("profile");
Profile.allow({
insert: function(userId, doc) {
return !!userId;
},
update: function(userId, doc) {
return !!userId;
},
remove: function(userId, doc) {
return !!userId;
}
});
var Schemas = {};
Schemas.Profile = new SimpleSchema({
userId: {
type: String,
optional: true
},
firstName: {
type: String,
optional: false,
},
familyName: {
type: String,
optional: false
}
});
Profile.attachSchema(Schemas.Profile);
if (Meteor.isServer) {
Meteor.publish('private.profile', function() {
return Profile.find({});
});
}
路径:
路径:client/main.js
Template.main.onCreated(function() {
this.autorun(() => {
this.subscribe('private.profile');
});
});
谢谢。我一定会读那个tut! – bp123
没有问题。我的答案是否适合你? – Sean
是的。我错过了一堆需要的文件。你指出了。谢谢您的帮助。 – bp123