The ORM used by sails.js is called waterline. I have been playing around with it for a couple of days now and noticed some subtle bugs, especially when associations are involved.
Fortunately, you can enable logging of all queries to the (server) console by setting the environment variable
true when lifting sails:
$ LOG_QUERIES=true sails lift
This makes it much easier to figure out if strange behavior is caused by a bug in your own code or in waterline itself.
In case you’re working with postgres you can check this https://github.com/balderdashy/waterline/issues/555#issuecomment-392603393
Note that this flag has stopped working in the newer versions of waterline. You can use `DEBUG=query sails lift` instead.