always love tech

初次使用meteor所遇到的一个问题:

insert failed: Method '/pictures/insert' not found

提示没有这个方法,然后可以看到在mongodb数据库中确实没有pictures这个collection;

于是开始google it,发现stackoverflow上面有个问题很相似,

Pictures=new Mongo.Collection( 'pictures')
// Meteor.subscribe("pictures");
// Pictures.allow({
// insert: function () {
// return true;
// },
// update: function () {
// return true;
// },
// remove: function () {
// return true;
// }
// });

加上上面注释的代码后发现并没什么卵用;

后来找了许久才发现要保证server端同时进行声明才可以;最终在server加上

Pictures=new Mongo.Collection( 'pictures')
//problem solved PS:我用的是js,并木有用coffeescript,如果用coffee似乎用
@Pictures=new Mongo.Collection 'pictures'
就能保证全局了,还没尝试。。。
最后不得不说meteor的DDP实现的hot code push碉堡了
demo已经发布到我的github,欢迎一起讨论tech
https://github.com/z-pro/gallery-by-meteor
04-26 20:23