在使用 meteor 集合时从开发控制台收到“找不到方法 [404]”错误

Getting a "method not found [404]" error from dev console while working with meteor collections

本文关键字:找不到方法 方法 找不到 错误 meteor 集合 控制台 开发      更新时间:2023-09-26

我正在尝试使用由我的 mongo 模式制作的自动表单将文档插入我的 meteor 集合中,但是当我按下提交按钮时,它在开发控制台中给了我一个"找不到方法 [404]"错误。 我相信它来自以下代码:

GameList.allow({
  insert: function(userId, doc){
    return !!userId;
  }
});

这允许用户在以用户身份登录时将文档添加到数据库中。如果没有此代码,我将收到"未授权 [403]"错误,因为我从我的 meteor 应用程序中取出了不安全的软件包。 知道是什么原因导致此方法未找到错误吗?

自动套用代码:

{{> quickForm collection="GameList" id="insertGameForm" type="insert" class="newGameForm"}}

自动表单的架构:

GameListSchema = new SimpleSchema({
  title: {
    type: String,
    label: "Title"
  },
  platform: {
    type: String,
    label: "Platform"
  },
  category: {
    type: String,
    label: "Category"
  },
  gameRank: {
    type: String,
    label: "GameRank"
  },
  auth: {
    type: String,
    label: "Author",
    autoValue: function(){
      return this.userId
    },
    autoform: {
      type: "hidden"
    }
  }
});
GameList.attachSchema(GameListSchema);
我相信

这种情况正在发生,因为根据 Meteor 文档,您的允许/拒绝规则应该在服务器上运行。 尝试将它们放在服务器端代码上并再次运行。