Below is my sample code ,if run this code db not defined error is came how to to solve this error.But my in tension is user details are store in mongoDb after submit the form .And send the mongodb command prompt operations .Plz Help me any body.....
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
});
}
});
}