Great question. Sails implements many-to-many associations using the "join" model. It does not appear in the api / models folder, but you can request it if you need to. In your case, it will 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; The easiest way to figure this out is to run the sails console and do:
sails.util.keys(sails.models)
to list all the models in the system.
sgress454
source share