Sails.js模型:创build2个关联自失败

我很新的Nodejs和帆。 我正在实现一个类似于Twitter的服务器。 在用户模型中,应该有两个字段:follower和follow,这两个字段是模型“用户”本身的关联。

我的问题是,当模型只有1个关联,追随者或追随者,它的工作。 但是,当追随者和追随者都包括在内时,就会出现错误。

代码是这样的:

module.exports = { attributes: { alias: { type:'string', required: true, primaryKey: true }, pwd: { type: 'string', required: true }, follower: { collection: 'user', via: 'alias' }, following:{ collection: 'user', via: 'alias' } } 

该代码将导致这样的错误:

  usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema/references.js:115 throw new Error('Trying to associate a collection attribute to a model tha ^ Error: Trying to associate a collection attribute to a model that doesn't have a Foreign Key. user is trying to reference a foreign key in user at References.findReference (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema/references.js:115:11) at References.addKeys (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema/references.js:72:22) 

       

网上收集的解决方案 "Sails.js模型:创build2个关联自失败"