How can I define functions/instance method for objects in Sails ?
In Waterline doc (https://github.com/balderdashy/waterline) they say:
var User = Wa
You can define instance methods in models with sails 0.9.0 like this:
module.exports = {
attributes: {
name: {
type: 'STRING',
defaultsTo: 'zooname'
},
instanceMethod: function(){
// your code
}
}
};
Usage example:
ClientHit.findOne({}).exec(function(err, model){
model.instanceMethod(); //use your instance method
});