Sails.js Model: create 2 association to self failed

僤鯓⒐⒋嵵緔 提交于 2019-11-30 20:27:14

For such usage your model definition is incorrect, namely the via keywords. As per the waterline associations docs the via keyword references the other side of the association. So, for a follower the other side is following and vice-versa. In other words:

follower: {
  collection: 'user',
  via: 'following'
},
following:{
  collection: 'user',
  via: 'follower'
}

You can check a full working example at: https://github.com/appscot/sails-orientdb/blob/master/test/integration-orientdb/tests/associations/manyToMany.selfReferencing.js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!