-
Notifications
You must be signed in to change notification settings - Fork 0
/
hbt.js
36 lines (28 loc) · 845 Bytes
/
hbt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
if (Meteor.isClient) {
Meteor.subscribe('books');
var BooksCollection = new Meteor.Collection('books');
Session.setDefault('counter', 0);
Template.hello.helpers({
book: function () {
return BooksCollection.find().fetch();
}
});
Template.displayBook.events({
'click .remove': function(event, template) {
var bookid = template.find('.bookid').childNodes[0].textContent;
BooksCollection.remove({_id: bookid});
return false;
}
});
}
if (Meteor.isServer) {
var BooksCollection = new Meteor.Collection('books', {
idGeneration: 'MONGO'
});
Meteor.publish('books', function() {
return BooksCollection.find();
})
Meteor.startup(function () {
// code to run on server at startup
});
}