2012-07-28 53 views
1

我试图更新我的流星应用程序中的一个集合,并且出现以下错误:允许在流星应用程序中使用授权分支

更新失败:403 - 访问被拒绝。无法替换受限集合中的文档。

在我有以下代码服务器:

Songs = new Meteor.Collection("songs"); 
    PlayLists = new Meteor.Collection('playlists'); 
    PlayChannels = new Meteor.Collection('playchannels'); 

    Meteor.publish('songs', function() { 
     return Songs.find(); 
    }); 
    Meteor.publish('playlists', function() { 
     return PlayLists.find(); 
    }); 
    Meteor.publish('playchannels', function() { 
     return PlayChannels.find(); 
    }); 

    Meteor.startup(function() { 
     Songs.allow({ 
     insert: function() { return true; }, 
     update: function() { return true; }, 
     remove: function() { return true; }, 
     fetch: function() { return true; } 
     }); 
     PlayChannels.allow({ 
     insert: function() { return true; }, 
     update: function() { return true; }, 
     remove: function() { return true; }, 
     fetch: function() { return true; } 
     }); 
     PlayLists.allow({ 
     insert: function() { return true; }, 
     update: function() { return true; }, 
     remove: function() { return true; }, 
     fetch: function() { return true; } 
     }); 
    }); 

而且我打出电话如下:

PlayChannels.update({_id: Session.get('playchannel')},{current:Session.get('current')}); 

我在做什么错?

+0

我在这里也面临同样的问题。你怎么处理它BTW? – 2012-09-30 20:25:44

+0

同样在这里...不知道该怎么做。 – TigrouMeow 2012-10-13 04:23:23

回答

0

这个问题出了什么问题。正确的方法是:

PlayChannels.update({ 
    _id: Session.get('playchannel') 
}, { 
    $set: { 
     current: Session.get('current') 
    } 
}) 
0

allow的fetch选项应返回一个数组,而不是布尔值,或者只是将其完全删除。我认为这应该可以解决这个问题,因为在同一场景中,我允许失败,因为提取返回一个布尔值,因此没有考虑更新的限制。

Songs.allow({ 
     insert: function() { return true; }, 
     update: function() { return true; }, 
     remove: function() { return true; } 
     });