This is the weirdest thing, for some reason, even with autocompletion enabled, I can’t access the collection from the browser console. The code below is a simple list program in which you can enter items into the collection, and it will be displayed as a list on the screen. In the console, when I try to access the database by typing People.find () or People.find (). Fetch () throws an error 'ReferenceError: cannot find variable: People'
How did it happen that I have auto-update, so I thought that I could access the collection from the client?
the code:
var People = new Meteor.Collection("people"); if (Meteor.isClient) { console.log(People.find()); Template.personList.people = function () { return People.find(); }; Template.personForm.events({ 'click button': function(e, t) { var el = t.find("#name"); People.insert({ name: el.value }); el.value = ""; } }); Template.person.editing = function () { return Session.get("edit-" + this._id); }; Template.person.rendered = function () { var input = this.find("input"); if(input) { input.focus(); } }; Template.person.events({ 'click .name': function (e, t) { Session.set("edit-" + t.data._id, true); }, 'keypress input': function (e, t) { if (e.keyCode == 13) { People.update(t.data._id, { $set: { name: e.currentTarget.value }}); Session.set("edit-" + t.data._id, false); } }, 'click .del': function (e, t) { People.remove(t.data._id); } }); }
source share