How do I make a recursive relationship in sails?
Diagram:
I want to have an array with all friend user ids, for example:
{
id: 1
name: 'Javi',
email: '123@gmail.com',
friends: [2]
}
{
id: 2,
name: 'User2',
email: '321@gmail.com',
friends: [1]
}
I tried with this:
// User.js <-- model
attributes:{
name: 'string',
email:{type:'email', required: true}
friends:{
collection: 'User',
via: 'friends'
},
}
I cannot achieve this.
+3
source to share