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')});

私は何が間違っているのですか?

4

2 に答える 2

0

allow の fetch オプションは、ブール値ではなく配列を返すか、完全に削除する必要があります。同じシナリオで、フェッチがブール値を返していたために失敗を許可したため、更新の許容範囲を取り込んでいないため、これで解決すると思います。

Songs.allow({
        insert: function () { return true; },
        update: function () { return true; },
        remove: function () { return true; } 
      });
于 2012-11-18T17:04:20.457 に答える
0

間違っていたのは電話でした。それを行う正しい方法は次のとおりです。

PlayChannels.update({
    _id: Session.get('playchannel')
}, {
    $set: {
        current: Session.get('current')
    }
})
于 2012-07-28T22:40:21.157 に答える