Skip to content

Instantly share code, notes, and snippets.

@kedarmhaswade
Created June 5, 2014 20:32
Show Gist options
  • Select an option

  • Save kedarmhaswade/6d1337dc7e840c25b6b8 to your computer and use it in GitHub Desktop.

Select an option

Save kedarmhaswade/6d1337dc7e840c25b6b8 to your computer and use it in GitHub Desktop.
A find method in a Sails Controller that works with disk adapter but not with mysql adapter ...
module.exports = {
//...
find: function(req, res) {
Items
.find()
.exec(function(err, items) {
if (err) {
res.send(err);
} else if (items) {
items.forEach(
function setUser(item) {
Users.find({ where: {id: review.userId} }, function(err, users) {
item.user = users[0];
});
}
);
res.send(items);
} else {
res.send({});
}
});
},
// other rest route methods
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment