1
下面是我的示例代碼,如果運行這段代碼DB沒有定義錯誤是來如何解決這個error.But我在緊張的用戶詳細信息正在店mongoDb
提交後的形式。而發送mongodb
命令提示符操作.Plz幫我任何身體.....DB沒有被定義使用`流星Js`在`mongoDB`錯誤
user = new Meteor.Collection('test');
//Metro Client
if (Meteor.isClient) {
Template.hello.events({
'submit #loginform' : function (e , t)
{
e.preventDefault();
var username = t.find('#username').value;
var password = t.find('#password').value;
var email=t.find('#email').value;
//Insert values Into mongodb
user.insert
({
username:username,
password: password,
email:email,
});
j = { name : "username" }
db.test.insert(j);
console.log("username="+username);
console.log("password="+password);
console.log("email="+email);
}
});
// Send email is client
Meteor.call('sendEmail',
'[email protected]',
'[email protected]',
'Hello from Meteor!');
}
//Metro Server
if (Meteor.isServer) {
Meteor.startup(function() {
});
// Send email is Server
Meteor.methods({
sendEmail: function (to, from, subject, text) {
//console.log("email="+to);
process.env.MAIL_URL = 'smtp://[email protected]:****@smtp.gmail.com:587';
check([to, from, subject, text], [String]);
this.unblock();
Email.send({
to: to,
from: from,
subject: subject,
text: text
});
}
});
}