Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating a list using meteor

Hi I am creating a money lend tracking website using meteor. It is my first attempt to learn meteor js. I tried writing the following piece of code in my js file

var lists = new Meteor.Collection("Lists");

But when I go back in Chrome developer console after refreshing page and type

lists
ReferenceError: lists is not defined
get stack: function () { [native code] }
message: "lists is not defined"
set stack: function () { [native code] }
__proto__: Error

Is there something i am missing ? Could any one help me.

like image 449
sreeprasad Avatar asked Dec 02 '25 06:12

sreeprasad


1 Answers

You can't access lists from your web console because code is scoped with each file. In meteor your code would be run as

function() {
    var lists = new Meteor.Collection("Lists");
    ....
}

So to access your collection in the console you need to globally scope it by changing your line to:

lists = new Meteor.Collection("Lists");

So that lists can be used anywhere such as other files and the webkit console

like image 122
Tarang Avatar answered Dec 03 '25 20:12

Tarang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!