Waterline ORM错误:错误:尝试访问未定义的集合字符串



我正在使用帆版本0.12与Waterline Orm进行生成模型。我在尝试运行sudo sails lift命令时会遇到此错误Error: Trying to access a collection string that is not defined

module.exports = {
  attributes: {
    manufacturer_name: {
      type: 'string'
    },
    manufacturer_logo_url: {
      type: 'string'
    },
    manufacturer_archived_status: {
      type: 'boolean'
    },
    manufacturer_tabs: {
      model: 'manufacturer_tabs'
    },
    brands: {
      model: 'brands'
    }
  }
};

在与模型的关联中,模型的名称必须匹配模型的确切名称,即文件名。通常,您的型号(文件名(应以Java样式的骆驼(或pascalcase(表示法。因此,您的代码应该看起来像这样:

module.exports = {
  attributes: {
    manufacturer_name: {
      type: 'string'
    },
    manufacturer_logo_url: {
      type: 'string'
    },
    manufacturer_archived_status: {
      type: 'boolean'
    },
    manufacturer_tabs: {
      model: 'ManufacturerTabs'
    },
    brands: {
      model: 'Brands'
    }
  }
};

和您的相关模型应在具有名称ManufacerTabs.js和brands.js的文件中。

我的建议:避免使用C和系统编程样式符号,因为它在现代脚本语言中不再被接受,不包括Python。使用骆驼作为JavaScript代码。因此,请考虑使用Manufacturername,Manufacturer_logo_url使用ManufacturerLogourl等代替Manuftory_name。

最新更新