未在启动时自动创建流星集合并且自动形式不会发布到mongo db

Vin*_*Dev 9 mongodb meteor meteor-blaze meteor-autoform meteor-collection2

我是meteor和mongo db的新手.我正在使用meteor@1.3.4.1申请.我正在创建一个名为'/imports/api/collections/recipe.js'的文件.在这里,我创建一个集合并将此文件导入'/server/main.js'和'/client/main.js'.在recipe.js中,我只发布Recipe集合,然后在我的客户端文件中我订阅它.直到这一点,一切都是正确的.然后我使用autoform创建一个表单,它运行良好并创建.但这种形式永远不会发布.

首先,我的假设是当服务器启动时,那时我的数据库应该创建一个名为recipe的集合,但事实并非如此.

其次,为什么autoform不起作用?我认为这是因为第一个原因.

在客户端,我通过蒙古(流星玩具)看到我的食谱收藏.

我的食谱文件 - '/imports/api/collections/recipe.js':

import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';

var RecipesCollection = new Mongo.Collection('recipes');

RecipesCollection.allow({
    insert(userId, doc){
        return !!userId;
    }
})

var RecipeSchema = new SimpleSchema({
    name: {
        type: String,
        label: "Name"
    },
    desc: {
        type: String,
        label: "Description"
    },
    author: {
        type: String,
        label: "Author",
        autoValue(){
            return this.userId
        },
        autoform:{
            type: "hidden"
        }
    },
    createdAt: {
        type: Date,
        label: "Created At",
        autoValue(){
            return new Date();
        },
        autoform:{
            type: "hidden"
        }
    }
});

RecipesCollection.attachSchema( RecipeSchema );

if (Meteor.isServer) {
  // This code only runs on the server
  Meteor.publish('recipes', function tasksPublication() {
    return RecipesCollection.find({author: this.userId});
  });
}

export const Recipes = RecipesCollection;
Run Code Online (Sandbox Code Playgroud)

我的服务器文件:'/ server/main.js':

import { Meteor } from 'meteor/meteor';
import '/imports/startup/server/start.js';
import '/imports/api/collections/recipe.js';
Run Code Online (Sandbox Code Playgroud)

我的客户端的js文件:

import { Template } from 'meteor/templating';
import { Recipes } from '/imports/api/collections/recipe.js';

import '/imports/ui/pages/NewRecipe.html';
Template.NewRecipe.onCreated(function bodyOnCreated() {
    Meteor.subscribe('recipes');
})
Template.NewRecipe.helpers({
    recipesCollection() {
        return Recipes;
    }
});
Run Code Online (Sandbox Code Playgroud)

新配方模板:

<template name="NewRecipe">
    <div class="new-recipe-container">
        {{> quickForm collection=recipesCollection id="insertRecipeForm" type="insert" class="new-recipe-form" }}
    </div>
</template>
Run Code Online (Sandbox Code Playgroud)

我正在使用包:Collection2和autoform.任何帮助或建议将不胜感激.谢谢

通过分配我的流星学习项目,随意使它工作.会非常致命的.- https://github.com/devin6391/meteorLearn1/tree/master/recipebook

Vin*_*Dev 1

好的解决了....对此感到非常羞愧,因为这又是一个流星包的版本问题 - 'accounts-ui'。有时,由于著名的 CDN 问题,软件包在印度无法升级。

尽管如此,集合并不是自己创建的。我必须去 mongoDB 控制台并自己创建它。然后只将 autoform 发布到它