javascript - Displaying data from Meteor 1.0 -
on startup add together info meteor json file this:
13 if (meteor.isserver) { 14 15 //startup 16 meteor.startup(function () { 17 if(plugins.find().count() === 0) { 18 var plugins_data = json.parse(assets.gettext('plugins_data.json')); 19 _.each(plugins_data, function(){ 20 plugins.insert( plugins_data ); 21 console.log('created new plugin record'); 22 }); 23 } 24 }); 25 26 }
i have collection called plugins
looks using db.plugins.find().pretty()
in meteor mongo
view data:
"222" : { "plugin-name-one" : { "data" : [ { "id" : 888, "title" : "" } ] } }, "223" : { "plugin-name-two" : { "data" : [ { "id" : 555, "title" : "" } ] } },
here how i'm trying display data:
3 if (meteor.isclient) { 4 5 template.list.helpers({ 6 list_all: function() { 7 homecoming plugins.find(); 8 } 9 }); 10 11 }
and html template:
5 <body> 6 <h1>welcome meteor!</h1> 7 {{> list}} 8 </body> 9 10 11 <template name='list'> 12 {{#each list_all}} 13 <h1>{{name}}</h1> 14 {{/each}} 15 </template>
how show info field (and field name) plugin-name-1
, plugin-name-2
shown mongo collection? can't find info docs. how display info correctly?
you don't have pool called name
.
also, improve way check if there collection created utilize if(plugins.findone())
.
what's more, enumerate_this
object, after rename {{name}}
homecoming [object object]
if remember correctly
edit: ok after edit think know want do, imo construction should this
{ name:"plugin_one", "data" : [ { "id" : 888, "title" : "" } ] }, { name:"plugin_two", "data" : [ { "id" : 888, "title" : "" } ] },
and assume want maintain more info in 1 plugin, , that's why there array, if not construction can this
{ name:"plugin_one", id : "888", title : "" }, { name:"plugin_two", id : "888", title : "" },
and in html can this:
<template name='list'> {{#each list_all}} <h1>{{name}} {{data.id}}</h1> {{/each}} </template>
or without array
<template name='list'> {{#each list_all}} <h1>{{name}} {{id}}</h1> {{/each}} </template>
javascript node.js mongodb meteor
No comments:
Post a Comment