insert - inserting json data in meteor collection -


here's code. https://github.com/studiomockingbird/sh_meteor

its leaderboard example wwhere trying insert of own data in collections.

my data resides in lib/book.js , has been defined object (var mybook).

the code use inserting in leaderboard.js -

pages = new meteor.collection("pages"); if (meteor.isserver) {     meteor.startup(function () {         if(pages.find().count() === 0){             var pages = json.parse(mybook.stories);             (page in pages) {                 pages.insert(pages[page]);             }         }     }); } 

when try run code gives me

running on: http://localhost:3000/ exited code: 1 exited code: 1 exited code: 1 application crashing. waiting file change. 

what doing wrong? totally new meteor.

there couple of things need iron out:

remove scoping of book

you've used var mybook, using var mybook variable being scoped, or @ least 0.6.0 rc8, if you're getting book console.log don't worry now, if run later if 0.6.0 gives problems change around

using json.parse

you don't need parse json data object declared 1 change:

 var pages = json.parse(mybook.stories); 

to

var pages = mybook.stories; 

with changes i've managed function correctly.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -