Javascript 找不到集合
我将Meteorjs与cultofcoders:grapher软件包一起使用,当我尝试链接两个集合时,我发现了一个错误-Javascript 找不到集合,javascript,mongodb,meteor,Javascript,Mongodb,Meteor,我将Meteorjs与cultofcoders:grapher软件包一起使用,当我尝试链接两个集合时,我发现了一个错误- Error: Could not find a collection with the name: Products [invalid-collection] at Linker._validateAndClean (packages/cultofcoders:grapher/lib/links/linker.js:159:23) 下面是我的代码 products/coll
Error: Could not find a collection with the name: Products [invalid-collection]
at Linker._validateAndClean (packages/cultofcoders:grapher/lib/links/linker.js:159:23)
下面是我的代码
products/collection.js
import {Mongo} from "meteor/mongo";
import ProductSchema from "./schema"
const Products = new Mongo.Collection("products");
Products.attachSchema(ProductSchema);
Products.attachBehaviour("timestampable");
export default Products;
products/link.js
import Products from "./collection";
import Categories from "../categories/collection";
Products.addLinks({
productsCategory:{
type: "one",
collection: "Categories",
field: "category"
}
});
您可以在链接中找到完整的回购协议
附加架构时不会触发错误,但为什么在尝试添加链接时会出现错误?
我这里缺少什么?确保服务器端和客户端都正确导入了
products/collection.js
。@HarryAdel,它已经在客户端和服务器端导入了。我甚至可以在collection中插入数据。您能提供类别collection的配置吗?还有可能是你的项目的一个迷你版本的repo,这样我们可以更好地调试这个问题。@HarryAdel,你可以在repo缺少.meteor
和包.json的链接上找到完整的repo,所以我不得不临时修改。我克隆了这个,添加了你的文件,删除了所有不必要的文件。你瞧,它真管用!但ofc如果没有自己的软件包设置等等,这绝对是不准确的。因此,请确保示例是正确的、有效的,并且代表您的实际设置。这是我工作的地方。