Model.distinct("Age").done(function(err, ward) {
if(err)
return next(err);
if(!ward)
return next();
res.json(ward);
});
After executing this code, it gives the following error:
TypeError: Object [object Object] has no method 'distinct'
But distinct works in robomongo. How can I rectify the error?
Currently Walterline (the ORM of sails) dont support distinct()-function.
But you can use the native()-function to get direct access to the native mongo driver:
Modelname.native(function(err,coll){
coll.distinct("Age", function(err,result){
res.json(result);
});
});
See: https://sailsjs.com/documentation/reference/Models/Model-Methods/native.html