用 MUP 部署 Meteor,我的 collections 没有部署
Meteor deploy with MUP, my collections are not deployed
我用 meteor 创建我的应用程序,并用 MUP 将它部署在我自己的服务器上。这
部署成功,但数据库没有我的 collections.
我在文件 lib/collections/name_collection.js
中定义了 collection。这是文件的示例:
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 中部署,但结果是一样的。
你能帮帮我吗?
这符合预期。 Mongo 是一个 NoSQL 数据库。一旦您向其中插入数据,就会立即创建集合。您的数据库没有数据,因此没有集合。任何 mongo 数据库也是如此,例如通过 mup deploy
托管的 meteor.com
数据库(如果您使用 compose 或像上面脚本中那样的本地数据库)。
MUP 或 meteor deploy
,如果您有意,请不要上传本地数据库的内容。您必须使用 mongodump
和 mongorestore
自己执行此操作:https://docs.compose.io/backups/mongodump-mongorestore.html
您可以从 mongodb.org
中获取 mongorestore & mongodump 二进制文件
您可以转储本地数据库(如果您 运行 meteor 在端口 3000 上 - 添加一个):
mongodump --port 3001
这将创建 dump
文件夹,您可以使用该文件夹通过 mongorestore
进行恢复,这可能需要更多身份验证详细信息,如上面 compose.io 文章中所述。
我用 meteor 创建我的应用程序,并用 MUP 将它部署在我自己的服务器上。这 部署成功,但数据库没有我的 collections.
我在文件 lib/collections/name_collection.js
中定义了 collection。这是文件的示例:
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 中部署,但结果是一样的。
你能帮帮我吗?
这符合预期。 Mongo 是一个 NoSQL 数据库。一旦您向其中插入数据,就会立即创建集合。您的数据库没有数据,因此没有集合。任何 mongo 数据库也是如此,例如通过 mup deploy
托管的 meteor.com
数据库(如果您使用 compose 或像上面脚本中那样的本地数据库)。
MUP 或 meteor deploy
,如果您有意,请不要上传本地数据库的内容。您必须使用 mongodump
和 mongorestore
自己执行此操作:https://docs.compose.io/backups/mongodump-mongorestore.html
您可以从 mongodb.org
中获取 mongorestore & mongodump 二进制文件您可以转储本地数据库(如果您 运行 meteor 在端口 3000 上 - 添加一个):
mongodump --port 3001
这将创建 dump
文件夹,您可以使用该文件夹通过 mongorestore
进行恢复,这可能需要更多身份验证详细信息,如上面 compose.io 文章中所述。