简体   繁体   中英

Build a new project in meteor, an error when inserting into mongoDB

I am new to meteor , and in my new (nearly blank) project I have in my main.js following code:

console.log("Hello world");
PlayersList = new Mongo.Collection('players');

On the JavaScript console I got this error:

PlayersList.insert({ name: "David", score: 0 }); "YEK8N2KYHH2YeeHTr" debug.js:41 insert failed: Method '/players/insert' not found

Please help!

As you are using it at the client side, you can do it like:

PlayersList = new Mongo.Collection(null);
PlayersList.insert({ name: "David", score: 0 });

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM