Using sails js console to output model

So you just started using sails.js It can be sometimes tricky to get information from the database. One sure way is to visit the route
/model/:id
this should return an instance of the model. But what if you want to debug your app in the console: You should go to your terminal and enter
sails console
this will spin up your app and you will be able to use the models by their capital case name e.g. to get the first user, you enter
let u = User.findOne({id:1}) u.exec((err,result)=> console.log(result))
This should give you the result for the first user in your database.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top