使用MUP部署Meteor,我的集合未部署

时间:2015-05-06 09:03:20

标签: javascript mongodb deployment collections meteor

我使用meteor创建我的应用程序,并使用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中部署,但结果是一样的。

你能帮助我吗?

1 个答案:

答案 0 :(得分:0)

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

MUP或meteor deploy不会上传您本地数据库的内容,如果这是您的意图。您必须使用mongodumpmongorestorehttps://docs.compose.io/backups/mongodump-mongorestore.html

自行完成此操作

你可以得到mongorestore&来自mongodb.org的mongodump二进制文件

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

mongodump --port 3001

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

相关问题