无法获得发布集合的应用

时间:2017-02-13 23:12:30

标签: meteor meteor-blaze

进口和出口新手。我正在努力弄清楚我在这里做错了什么。我想在Meteor中使用推荐的文件结构时发布我的Profile.js集合。

路径:imports/api/profile/server/publications.js

import { Meteor } from 'meteor/meteor';
import { Profile } from '../../profile/Profile.js';

Meteor.publish('profile.private', function() {
  if (!this.userId) {
    return this.ready();
  }
  return Profile.find({
    userId: this.userId
  });
});

路径: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';

SimpleSchema.debug = true;

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,
      // regEx: SimpleSchema.RegEx.Id,
      optional: true
    },
    firstName: {
        type: String,
        optional: false,
    },
    familyName: {
        type: String,
        optional: false
    },
    mobileNumber: {
      type: ContactNumberSchema,
      optional: false
    },
});

Profile.attachSchema(Schemas.Profile);

路径:client/pages/newSite/users-all/main.js

import { Template } from 'meteor/templating';

import { Profile } from '../../../../imports/api/profile/Profile.js';
import './main.html';

Template.main.onCreated(function() {
    this.autorun(() => {
        this.subscribe('profile.private');
    });
});

0 个答案:

没有答案