Build complex Model.find request Build complex Model.find request express express

Build complex Model.find request


Ok i successfully found how to do !

So the goal was to convert this request :

Status.query("SELECT Status.* FROM Status,User where Status.user = User.id and User.isPrivate = false group by status.id  order by status.id desc limit "+limit+" offset "+offset, function(err, status) {            if(err) return next(err);            console.log(status)            console.log(res)            res.json(200,status);        });

To a Model.find request using Sails.js syntax in state of mysql. Here you go : (without pagination but its easy to find how to do)

Status.find({}).populate('user',{isPrivate:'false'}).exec(function(status,err){                if(err) return next(err);                console.log(status)                console.log(res)                res.json(200,status);            });

Have fun!