-
Notifications
You must be signed in to change notification settings - Fork 0
/
fishseed.js
executable file
·44 lines (34 loc) · 1.04 KB
/
fishseed.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
37
38
39
40
41
42
43
44
coll = new Meteor.Collection('myCol');
if (Meteor.isClient) {
Meteor.subscribe('myCol') // <- this suscirbes to everything in myCol
Template.hello.greeting = function () {
return "Welcome to fishseed.";
};
Template.fish.seed = function () {
return coll.find();
};
Template.hello.events({
'click input': function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
}
});
}
if (Meteor.isServer) {
Meteor.startup(function(){
// Having the option to delete all documents is nice if I want to change the structure of the collection
if ( coll.find().count() > 0 ){
// Remove all documents in the collection to prevent any duplicates.
coll.remove({});
};
for (i=0;i<seedData.length;i++){
coll.insert(seedData[i]);
}
});
/* Insert here */
Meteor.publish('myCol', function(){
return coll.find() // <- publishes everything in myCol
})
/* end insert */
}