【问题标题】:Meteor deploy with MUP, my collections are not deployedMeteor 使用 MUP 部署,我的集合没有部署
【发布时间】:2015-07-16 07:40:29
【问题描述】:

我使用流星创建我的应用程序,并使用 MUP 将其部署在我自己的服务器中。这 部署成功,但数据库没有我的收藏。

我在文件lib/collections/name_collection.js 中定义了集合。这是文件的示例:

campaigns = new Mongo.Collection("campaigns");
campaigns.initEasySearch(['name','startDate','endDate']);

campaigns.newSchema=function(){
    return new SimpleSchema({
        name:{
            type: String,
            label: 'Nome'
        },
        startDate:{
            type: 'datetime',
            label: 'Data inizio'
        },
        endDate:{
            type: 'datetime',
            label: 'Data fine'
        }
    });
};
campaigns.editSchema=function(){
    return new SimpleSchema({
        c_id:{
            type: String,
            label: 'id'
        },
        editName:{
            type: String,
            label: 'Nome'
        },
        editStartDate:{
            type: 'datetime',
            label: 'Data inizio'
        },
        editEndDate:{
            type: 'datetime',
            label: 'Data fine'
        }
    });
};

SimpleSchema.messages({
    "required name": "Il [label] è richiesto",
    "required startDate": "La [label] è richiesto",
    "required endDate": "La [label] è richiesto"
});

campaigns.allow({
    insert: function (userId, doc) {
        // the user must be logged in, and the document must be owned by the user
        return (userId && doc.user === userId);
    },
    update: function (userId, doc, fields, modifier) {
        // can only change your own documents
        return doc.user === userId;
    },
    remove: function (userId, doc) {
        // can only remove your own documents
        return doc.user === userId;
    },
    fetch: ['user']
});

campaigns.deny({
    update: function (userId, docs, fields, modifier) {
        // can't change owners
        return _.contains(fields, 'owner');
    }
});

和 mup.json 文件:

{
  // Server authentication info
  "servers": [
    {
      "host": "168.235.151.xxx",
      "username": "dvterritorg", // develop user
      "password": "xxxxxx"
      // or pem file (ssh based authentication)
      //"pem": "~/.ssh/id_rsa"


    }
  ],

  // Install MongoDB in the server, does not destroy local MongoDB on future setup
  "setupMongo": true,

  // WARNING: Node.js is required! Only skip if you already have Node.js installed on server.
  "setupNode": true,

  // WARNING: If nodeVersion omitted will setup 0.10.36 by default. Do not use v, only version number.
  "nodeVersion": "0.10.36",

  // Install PhantomJS in the server
  "setupPhantom": true,

  // Application name (No spaces)
  "appName": "dvterritorg",

  // Location of app (local directory)
  "app": ".",

  // Configure environment
  "env": {
    "ROOT_URL": "http://dv.xxxxxx.it",
    //"MONGO_URL": "mongodb://dvterritorg:xxxxxx@127.0.0.1/dvterritorg",
    "METEOR_ENV": "production"
  },

  // Meteor Up checks if the app comes online just after the deployment
  // before mup checks that, it will wait for no. of seconds configured below
  "deployCheckWaitTime": 60
}

我尝试在meteor.com 和compose.io 中进行部署,但结果是一样的。

你能帮帮我吗?

【问题讨论】:

    标签: javascript mongodb deployment collections meteor


    【解决方案1】:

    这符合预期。 Mongo 是一个 NoSQL 数据库。只要您将数据插入其中,就会生成集合。您的数据库没有数据,因此没有集合。任何 mongo 数据库也是如此,例如通过 mup deploy 托管的 meteor.com (如果您使用 compose 或上面脚本中的本地数据库)。

    MUP 或meteor deploy,如果您有意,请不要上传本地数据库的内容。您必须自己使用 mongodumpmongorestore 执行此操作:https://docs.compose.io/backups/mongodump-mongorestore.html

    您可以从mongodb.org 获取 mongorestore 和 mongodump 二进制文件

    您可以转储本地数据库(如果您在端口 3000 上运行流星 - 添加一个):

    mongodump --port 3001
    

    这会创建 dump 文件夹,您可以使用 mongorestore 进行恢复,这可能需要更多身份验证详细信息,如上面 compose.io 文章中所述。

    【讨论】:

      猜你喜欢
      • 2017-08-05
      • 1970-01-01
      • 2016-07-27
      • 2015-11-01
      • 2015-11-10
      • 1970-01-01
      • 2016-11-27
      • 2014-02-12
      • 1970-01-01
      相关资源
      最近更新 更多