我如何使用Meteor简单模式与meteor页面

刚开始玩meteor,我正在寻找meteor-simple-schemameteor-pages工作

原理很简单,我只是玩他们提供的示例todos应用程序,并希望添加无限滚动来加载更多的待办事项。 但是我不能同时工作。

这是我的默认meteor-simple-schema

 Todos = new Meteor.Collection('todos', {}); Schema = {}; Todos.attachSchema(new SimpleSchema({ text: { type: String, label: "Name", max: 200, min: 2 }, createdAt: { type: Date, label: "Created", optional: false }, creatorId: { type: String, label: "Creator", optional: false }, done: { type: Boolean, defaultValue: false, label: "Done?", optional: true } })); 

然后我把new Meteor.Collection('todos') new Meteor.Pages('todos') ,甚至new Meteor.Pagination('todos')

但是架构会产生错误。 我怎样才能使两个工作?

这里是错误:

 W20150317-22:47:23.197(1)? (STDERR) ~/.meteor/packages/meteor-tool/.1.0.41.azxhr5++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:173 W20150317-22:47:23.197(1)? (STDERR) throw(ex); W20150317-22:47:23.197(1)? (STDERR) ^ W20150317-22:47:23.199(1)? (STDERR) TypeError: Object #<Pages> has no method 'attachSchema' W20150317-22:47:23.200(1)? (STDERR) at app/collections/todos.js:25:7 W20150317-22:47:23.200(1)? (STDERR) at app/collections/todos.js:60:3 

所以这是一个相当古老的问题,但也许别人还在寻找答案。

要使用collection2的meteor-pages分页,只需要传递Meteor.Pagination的集合对象。

例:

 var Customers = new Mongo.Collection("customers"); var Schemas = {}; Schemas.Customer = new SimpleSchema({ … }); Customers.attachSchema(Schemas.Customer); var pages = new Meteor.Pagination(Customers, { … }); 

你把它改成新的Meteor.Pages还是Meteor.Pagination?

你可以发布模式创build什么问题吗?

代替

  TODOS = new Meteor.Collection('todos'); 

尝试一下

  TODOS = new Mongo.Collection('todos'); 

看起来好像这可能是你可能需要的。

在我看来,您没有将Collection2包添加到您的应用程序 – 这是定义attachSchema方法的地方。 以下命令应该可以解决问题。

 meteor add aldeed:collection2