Skip to content

Instantly share code, notes, and snippets.

@n8agrin
Created October 11, 2011 14:52
Show Gist options
  • Save n8agrin/1278294 to your computer and use it in GitHub Desktop.
Save n8agrin/1278294 to your computer and use it in GitHub Desktop.
# Javascript variant
var ListingsController = {
"index": function(req, res) {
var listings = listing.Listing.find({}, function(err, docs) {
res.send(docs);
});
},
"create": function(req, res) {
var l = new listing.Listing(req.body);
l.save(function(err, data) {
res.send(l);
});
}
}
# Coffeescript of the same
ListingsController:
index: (req, res) ->
Listing.find({}, (err, docs) -> res.send(docs))
create: (req, res) ->
listing = new Listing req.body
listing.save((req, res) -> res.send(listing))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment