I am new to Sails.js. I am trying to fetch data from my Mongo Db database "TestDB", I have a collection name "Components", so I created a Model named Components whcih contains the attributes of my colection
Components.js
module.exports = {
attributes: {
TaskId: {
type: 'string',
required: true
},
CompName: {
type: 'string'
},
InitialAttr: {
type: 'string'
},
Value: {
type: 'string'
}
}
};
ComponentsController.js
module.exports = {
GetComponentList : function(req, res){
Components.find({ CompName: 'ImageComponent'}).exec(function(err, data) {
if (err) return next(err);
res.json(data);
});
}
};
Route:
'/comp' : {
controller: 'components',
action: 'GetComponentList'
}
The above query executes fine in MongoVUE returning the dataset, but returns
[]
in Sails.js