I can initialize a waterline model using following way.
var user = Waterline.Collection.extend({
attributes: {
name: 'string',
password: 'string',
// Override toJSON instance method
toJSON: function() {
var obj = this.toObject();
delete obj.password;
return obj;
}
}
});
module.exports = user;
Then I tried to instantiated a waterline model in a different file using following method.
var user = require('./user'); user.find({ id: 1 }).exec(function(err, model) { return model.toJSON(); // Will return only the name });
But then I get the following error.
User.find({ "first_name": "lahiru" }).exec(function (err, model) {
^
TypeError: undefined is not a function
Is there a specific way to instantiated a user model from the initialized user. Any kind of help would be appreciated.