I am new to Nodejs and sails. I am implementing a server similar to Twitter. The user model must have 2 fields: the successor and the next, and 2 fields - this is the association of the user of the model.
My question is that the model has only 1 association, either a follower or the next one, it works. However, when both followers and subsequent ones are included, there will be an en error.
The code looks something like this:
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' } }
The code causes this error:
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)
source share