Skip to content

Instantly share code, notes, and snippets.

@billywhizz
Created July 10, 2011 15:10
Show Gist options
  • Save billywhizz/1074605 to your computer and use it in GitHub Desktop.
Save billywhizz/1074605 to your computer and use it in GitHub Desktop.
function handleFailure(err) {
next(new DbError(err));
}
function findBlog(blog) {
function setUsers() {
// do stuff
}
function setBlog() {
project.setUsers(users).on("success", setUsers).on("failure", handleFailure);
}
function createProject(project) {
project.setBlog(blog).on("success", setBlog).on("failure", handleFailure);
}
function findAll(users) {
if (!users) return res.send({ errors: "Users do not exist."});
Project.create(req.form.project).on("success", createProject).on("failure", handleFailure);
}
if (!exhibit) return res.send({ errors: "Blog does not exist."});
User.findAll(req.form.users).on("success", findAll).on("failure", handleFailure);
}
Blog.find(req.form.blog).on("success", findBlog).on("failure", handleFailure);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment