我开始和Meteor合作,我正在讨论第一期.我想在我的收藏中插入一个项目.我得到以下控制台日志错误.有人可以帮助流星菜鸟吗?
插入失败:找不到方法
这是导致错误的行:
Videos.insert({name: el.value});
Run Code Online (Sandbox Code Playgroud)
我的js文件:
var Videos = new Meteor.Collection("videos");
if (Meteor.isClient) {
Template.videoList.video = function() {
return Videos.find();
}
Template.videoForm.events({
'click button': function(e, t){
var el = t.find("#name");
Videos.insert({name: el.value});
el.value = "";
}
});
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试获取集合中的上一个和下一个项目.以下是我尝试过的,但它不起作用.我得到了结果,但他们没有以正确的顺序返回.有什么建议?
以前:
Meteor.videos.find({$lt: currentID}, {sort: {date: -1}, limit:1});
Run Code Online (Sandbox Code Playgroud)
下一个:
Meteor.videos.find({$gt: currentID}, {sort: {date: -1}, limit:1});
Run Code Online (Sandbox Code Playgroud)