SAILS:如何定义关联表mysql多个

SAILS:如何定义关联表mysql多个,mysql,node.js,sails.js,Mysql,Node.js,Sails.js,正如我在文档中读到的“Waterline将查看您的模型,如果它发现两个模型都具有指向彼此的集合属性,它将自动为您建立一个联接表。”我的问题是,Waterline如何知道哪个表是关联表,因为我现在遇到了一个错误 where子句中的未知列NaN 我使用MYSQL作为数据库,我的模型如下所示: Sells.js: module.exports = { autoCreatedAt: true, autoUpdatedAt: false, attributes: { createdAt

正如我在文档中读到的“Waterline将查看您的模型,如果它发现两个模型都具有指向彼此的集合属性,它将自动为您建立一个联接表。”我的问题是,Waterline如何知道哪个表是关联表,因为我现在遇到了一个错误

where子句中的未知列
NaN

我使用MYSQL作为数据库,我的模型如下所示:

Sells.js:

module.exports = {
  autoCreatedAt: true,
  autoUpdatedAt: false,
  attributes: {
    createdAt:{
        type:'datetime',
        columnName:'created'
    },
    qty_sold:{
        type:'float'
    },
    s_notes:{
        type:'string'
    },
    items: {
      collection: 'species',
      via: 'sales',
      dominant:true
    }
  }
};
Species.js:

    module.exports = {
  autoCreatedAt: false,
  autoUpdatedAt: false,
  attributes: {
    name:{
        type:'string',      
    },
    qty:{
        type:'float',   
    },
    sort:{
        type:'float',
    },
    quickbooks_listid:{
        type:'string'   
    },
    quickbooks_editsequence:{
        type:'string'   
    },
    isEdited:{
        type:'integer'
    },
    cut_fish:{
        type:'integer'
    },
    // Add a reference to Sells
    sales: {
      collection: 'sells',
      via: 'items',
      //dominant: true
    }
  }
id: {
  type: 'integer',
  primaryKey: true,
  autoIncrement: true
},

sells:{
  collection: "Sells", // match model name
  via: "Species" // match attribute name
}
})

我在mysql数据库中有两个现有表: 品种和销售

销售:

id: {
  type: 'integer',
  primaryKey: true,
  autoIncrement: true
},

species:{
  collection: "species", // match model name here
  via: "Sells", // match attribute name on other model
  dominant: true // dominant side
}
Species.js:

    module.exports = {
  autoCreatedAt: false,
  autoUpdatedAt: false,
  attributes: {
    name:{
        type:'string',      
    },
    qty:{
        type:'float',   
    },
    sort:{
        type:'float',
    },
    quickbooks_listid:{
        type:'string'   
    },
    quickbooks_editsequence:{
        type:'string'   
    },
    isEdited:{
        type:'integer'
    },
    cut_fish:{
        type:'integer'
    },
    // Add a reference to Sells
    sales: {
      collection: 'sells',
      via: 'items',
      //dominant: true
    }
  }
id: {
  type: 'integer',
  primaryKey: true,
  autoIncrement: true
},

sells:{
  collection: "Sells", // match model name
  via: "Species" // match attribute name
}