【发布时间】:2015-02-15 14:50:23
【问题描述】:
在 Ubuntu 上运行
Data.js
//Collections
Database = new Meteor.Collection('data');
if (Meteor.isClient) {
Template.main.data = function () {
var c = Database.find();
return c;
};
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
data.html
<head>
<title>data</title>
</head>
<body>
{{> main}}
</body>
<template name="main">
{{data}}
</template>
我使用 mongo 插入数据库:
> db.Database.insert({title: 'ShouldWork'});
> db.Database.find();
{ "_id" : ObjectId("5296403855ee6e1350b35afb"), "title" : "ShouldWork" }
然而,当我运行该站点时,它只返回 [object Object]..
应该有自动发布并且不安全, 这已经成为我学习框架的一大障碍。
【问题讨论】:
标签: mongodb object collections find meteor