About Mongo Collection

Hello,

I am trying to create a Mongo Collection (“Preop”) using the following code in the JS.

Preop = new Mongo.Collection(“preop_checklist_items”);

if (Meteor.isClient) {
// This code only runs on the client
Template.body.helpers({
preop_checklist_items: [
{ text: ‘Consent obtained’ },
{ text: ‘Labs and Diagnostic reports available’ },
{ text: ‘Implant(s) available’ },
{ text: ‘Films available’ },
{ text: ‘RN medications delivered’ },
{ text: ‘RN complete’ },
{ text: ‘Family waiting for surgeon’ },
{ text: ‘Surgical site marked’ },
{ text: ‘H&P updated’ },
{ text: ‘Anesthesia items complete’ }
]

});

Template.item.events({
“click .toogle-checked”: function () {
// Set the checked property to the opposite of its current value
Preop.update(this._id, {
$set: {checked: !this.checked}
});
},
“click .delete”: function () {
Preop.remove(this._id);
}
});
}

I am not sure if this is the correct way.

Thanks!

Seems wrong to do this client side. Are you trying to make these default fixtures? Look up the Discover Meteor book which explains how to do this properly.