My First MongoDB with Meteor
by b_long
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/mini-meteor/1.0.1/mini-meteor.min.js"></script>
<head>
<title>FirstProject</title>
</head>
<body>
<h1>Users List</h1>
{{> usersList}}
</body>
<template name="usersList">
<ul>
{{#each users}}
<li>{{fullname}}</li>
{{/each}}
</ul>
</template>
JavaScript
Users = new Meteor.Collection('users');
if (Meteor.isClient) {
Template.usersList.helpers({
users: function () {
return Users.find().fetch();
},
username: function () {
return username;
}
});
}
if (Meteor.isServer) {
if (Users.find().count() === 0)
{
user = 1;
Users.insert({
_id: "" + user++,
username: "praveen",
password: "Praveen12345",
fullname: "Praveen Kumar",
timestmp: new Date
});
Users.insert({
_id: "" + user++,
username: "vennila",
password: "Vennila@123",
fullname: "Vennila Sundar",
timestmp: new Date
});
Users.insert({
_id: "" + user++,
username: "sriram",
password: "EvanoOruthan123",
fullname: "Sriram Venkateswaran",
timestmp: new Date
});
}
}