Development Time > Accomplish in 10 lines what would otherwise take 1000, thanks to a reactive programming model that extends all the way from the database to the user's screen. > One language everywhere > Isomorphic APIs mean that the same code, written in the same language, can run on both client and server. > Live updates > Data updates live on the screen as it changes. Users can collaborate seamlessly. > Hot deploys > Type one command to push your app into production and update all connected browsers and devices. No need to go through the App Store.
(Meteor.isClient) { // This code only runs on the client Template.body.helpers({ tasks: function () { return Tasks.find({}); // select all the tasks from database } }); } JS $ meteor mongo MongoDB shell version: 2.4.9 connecting to: 127.0.0.1:3001/meteor meteor:PRIMARY> db.tasks.insert({ text: "Hello Mandalay!", createdAt: new Date() });
tasks" /> </form> HTML Template.body.events({ "submit .new-task": function (event) { // This function is called when the new task form is submitted var text = event.target.text.value; Tasks.insert({ text: text, createdAt: new Date() // current time }); // Clear form event.target.text.value = ""; // Prevent default form submit return false; } }); JS
<input type="checkbox" checked="{{checked}}" class="toggle-checked" /> <span class="text">{{text}}</span> </li> </template> HTML Template.task.events({ "click .toggle-checked": function () { // Set the checked property to the opposite of its current value Tasks.update(this._id, {$set: {checked: ! this.checked}}); }, "click .delete": function () { Tasks.remove(this._id); } }); JS
buttons {{> loginButtons}} /// modify form {{#if currentUser}} <form class="new-task"> <input type="text" name="text" placeholder="Type to add new tasks" /> </form> {{/if}} // Modify how the task listed <span class="text"><strong>{{username}}</strong> - {{text}}</span> HTML // Instead of email use USERNAME Accounts.ui.config({ passwordSignupFields: "USERNAME_ONLY" }); // Added the creator of the task Tasks.insert({ text: text, createdAt: new Date(), // current time owner: Meteor.userId(), // _id of logged in user username: Meteor.user().username // username of logged in user }); JS