Sails.js get many to many association count

白昼怎懂夜的黑 提交于 2019-12-01 04:50:17

Great question. Sails implements many-to-many associations using a "join" model. It doesn't show up in your api/models folder, but you can still query it if you need to. In your case it would be something like:

sails.models['user_phones__phone_users'].count({user_phones: userId}).exec(...)

The exact model name depends on your models and their via keys; simplest way to figure it out is to run sails console and do:

sails.util.keys(sails.models)

to list all the models in the system.

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