【问题标题】:Orionjs collection : Expected object, got undefinedOrionjs 集合:预期对象,未定义
【发布时间】:2023-04-01 10:40:02
【问题描述】:

Orionjs 在 Angular-Meteor 中工作,尤其是在集合中工作时,我遇到了一些麻烦。 我有我的旧 mongodb 声明,例如: Gallery = new Mongo.Collection('gallery') 等等。

作为documentation told,我写了 Gallery = new orion.collection('gallery') 但我得到的是

Error: Match error: Expected object, got undefined
    at exports.check (packages/check/match.js:34:1)
    at new orion.collection (packages/orionjs:collections/new.js:8:3)
    at meteorInstall.shared.collections.js (shared/collections.js:1:11)

所以我尝试使用这个框架从头开始一个项目。 事实上,它不适用于 Iron Router 和 Flow Router。

谁能给我任何暗示? 谢谢各位。

【问题讨论】:

  • 以前没用过Orionjs,但我认为它指的是orion.collection的第二个参数,你必须传入一个带有一些选项的对象(见docs.orionjs.org/v1.7/collections)。
  • 哦!我试图添加参数,但事实是,我必须创建一个模式。非常感谢您的提示。

标签: angularjs mongodb meteor meteor-orion


【解决方案1】:

理想情况下,OrionJS 需要一个模式详细信息,例如用于单复数名称的标签、导航详细信息、用于显示数据的表格布局等。这是一个典型的公司集合,如下所示:

Company = new orion.collection('company', {
  singularName: orion.helpers.getTranslation('company.singularName'), 
  pluralName: orion.helpers.getTranslation('company.pluralName'), 
  title: orion.helpers.getTranslation('company.title'),
  link: {
    title: orion.helpers.getTranslation('company.title'),
    parent: 'collections-abc'
  }, 

  tabular: {
    columns: [
      { data: '_id', title: orion.helpers.getTranslation('company.schema.id') },
      { data: 'name', title: orion.helpers.getTranslation('company.schema.name') }
    ]
  }
});

如果您不想直接显示页面,也可以传递一个空 JSON。通常它需要一个像上面显示的 JSON。

【讨论】:

    猜你喜欢
    • 2020-03-04
    • 2016-09-07
    • 2019-03-09
    • 2014-09-27
    • 1970-01-01
    • 2020-08-06
    • 1970-01-01
    • 2019-10-05
    • 1970-01-01
    相关资源
    最近更新 更多