Created
June 5, 2014 20:32
-
-
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 ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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